Kubernetes

http://kubernetes.io

Borg

kubectl

CoreOS flannel
Project Calico
Weave

http://get.k8s.io
SaltStck

kubectl

kubectl get nodes


touch 2048.yml

kubectl create -f 2048.yml

kubectl get nodes

kubectl get pods -o yaml 2048

kubectl get pods --selector="foo=bar"

kubectl label pods 2048 env=production

kubectl delete pod --selector="foo=bar"

kubectl get replicationscontrollers

kubectl get rc

kubectl create -f rc2048.yml

kubectl get rc

kubectl resize --replicas=4 rc rcgame

kubectl rollingupdate -h

touch wordpress.yaml

vim wordpress.yaml

apiVersion: v1
kind: Pod
metadata:
labels:
  name: wp
name: wp

spec:
  containers:
  - name: wordpress
    env:
    - name: WORDPRESS_DB_NAME
      value: wordpress
    - name: WORDPRESS_DB_USER
      value: wordpress
    - name: WORDPRESS_DB_PASSWORD
      value: wordpress
    - name: WORDPRESS_DB_HOST
      value: localhost
    images: wordpress
    ports:
    - containerPoert: 90
      hostPort: 80
  - name: mysql
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: wordpressdocker
    - name: MYSQL_DATABASE
      value: wordpress
    - name: MYSQL_USER
      value: wordpress
    - name: MYSQL_PASSWORD
      value: wordpress
    image: mysql
    ports:
    - containerPort:3306

kubectl create -f wordpress.yaml

kubectl logs wp wordpress



touch s.yml
vim s.yml

apiersion: v1
kind: Service
metadata:
  labels:
    name: wordpress
  name: wordpress
spec:
  createExternalLoadBalancer: true
  ports:
  - port: 80
  selector:
    name: wp

touch w.yml
vim w.yml

apiVersion: v1
kind: Service
metadata:
  labels:
    name: wordpress
  name: wordpress
spec:
  publicIPs: ["1.1.1.1"]
  ports:
    - port: 80
  selector:
    name: wp

touch m.yml
vim m.yml

apiVersion: v1
kind: ReplicationController
metadata:
  name: wp-mysql
spec:
  replicas: 1
  selector:
    tier: wp-mysql
  template:
    metadata:
      labels:
        tier: wp-mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        ports:
        - containerPort:3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: wordpressdocker
        - name: MYSQLDATABASE
          value: wordpress
        - name: MYSQL_USER
          value: wordpress
        - name: MYSQL_PASSOWRD
          value: wordpress


kubectl describe services/mysql

apiVersion: v1
kind: Pod
metadata:
  labels:
   tier: fe
  name: wp
spec:
  containers:
  - env:
    - name: WORDPRESS_DB_NAME
      value: wordpress
    - name: WORDPRESS_DB_USER
      value: wordpress
    - name: WORDPRESS_DB_PASSWORD
      value: wordpress
    - name: WORDPRESS_DB_HOST
      value: wordpress
    image: wordpress
    name: wordpress
    ports:
    - containerPort: 80
      hostPort: 80
      protocol: TCP


kubectl get nodes

kubectl run-container nginx --image=nginx --port=80

kubectl expose rc nginx --port=80 --public-ip=192.168.33.10

kubectl get pods

docker run --rm -it gcr.io/google_containers/hyperkube:v0.14.1 cat /etc/ kubernetes/manifests/master.json
...




###################

git clone https://github.com/how2dock/docbook.git
cd docbook/ch05/docker

docker-compose -f k8s.yml up -d
docker ps -a



###################

hyperkube apiserver -h




curl -sSL https://get.docker.com/ | sh

go version

dockerversion

git clone https://github.com/GoogleCloudPlatform/kubernetes.git
cd kubernetes
./build/run.sh hack/build-go.sh

curl http://localhost/8080/api

curl http://localhost:8080/version

curl http://localhost:8080/swggerapi/

curl http://localhost:8080/swggerapi/api/v1

curl http://localhost:8080/ping

hack/build-go.sh  cmd/kube-version-change


firewall-cmd --add-port=7080/{tcp,udp}

firewall-cmd --add-port=7080/{tcp,udp} --permanent

firewall-cmd --add-port=6443/{tcp,udp}

firewall-cmd --add-port=6443/{tcp,udp} --permanent

/etc/auth
password.username,useruid

hyperkube apiserver --portal_net=10.0.0.1/24 --etcd_servers=http://127.0.0.1:4001 --cluter_name=kubernetes --basic_auth_file=/etc/auth --v/2

kubectl config view

kubectl config set-cluster k --server=https://*******:6443 --insecure-skip-tls-verify=true

kubectl config set-context kcon --user=superadmin

kubectl config set-context kcon --cluster=k

kubectl config use-context kcon

curl -k -u test:test https://*****:6443/api