This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cloud:kubernetes:installation [2017/04/03 10:32] frank |
cloud:kubernetes:installation [2017/04/04 13:48] (current) frank |
||
---|---|---|---|
Line 5: | Line 5: | ||
1 master, 2 nodes | 1 master, 2 nodes | ||
- | RPM verisons | + | == RPM verisons == |
* On master: | * On master: | ||
* kubernetes-master, kubernetes-client - 1.5.2-0.2.gitc55cf2b.el7 | * kubernetes-master, kubernetes-client - 1.5.2-0.2.gitc55cf2b.el7 | ||
Line 13: | Line 13: | ||
* kubernetes-client, kubernetes-node - 1.5.2-0.2.gitc55cf2b.el7 | * kubernetes-client, kubernetes-node - 1.5.2-0.2.gitc55cf2b.el7 | ||
- | Services | + | |
+ | == Hostnames, IP, subnets, IP ranges == | ||
+ | * master and node IPs | ||
+ | * master: node-1(192.168.50.101/24, IP address is on eth1) | ||
+ | * nodes: node2(192.168.50.102/24), node-3(192.168.50.103/24), IP Address are on eth1 | ||
+ | * kubernetes cluster IP range: 10.254.0.0/16 | ||
+ | * flannel: iface on eth1, range: 172.30.0.0/16, subnetLen:24, type: vxlan | ||
+ | |||
+ | == Ports == | ||
+ | * etcd: 2379 | ||
+ | * kube-apiserver: 8080 | ||
+ | * kubelet: 10250 | ||
+ | * | ||
+ | |||
+ | == Services == | ||
* On master: | * On master: | ||
* etcd | * etcd | ||
Line 25: | Line 39: | ||
* flanneld | * flanneld | ||
- | Hostnames, subnets, IP ranges | + | == configuration files == |
- | * master and node IPs | + | * /etc/etcd/etcd.conf<code> |
- | * master: node-1(192.168.50.101/24) | + | ETCD_NAME=default |
- | * nodes: node2(192.168.50.102/24), node-3(192.168.50.103/24) | + | ETCD_DATA_DIR="/var/lib/etcd/default.etcd" |
- | * kubernetes cluster IP range: 10.254.0.0/16 | + | ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://node-1:2379" |
- | * flannel: 172.30.0.0/16, subnetLen:24, type: vxlan | + | ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,http://node-1:2379" |
+ | </code> | ||
+ | * /etc/kubernetes/config - for both master and node<code> | ||
+ | KUBE_LOGTOSTDERR="--logtostderr=true" | ||
+ | KUBE_LOG_LEVEL="--v=0" | ||
+ | KUBE_ALLOW_PRIV="--allow-privileged=false" | ||
+ | KUBE_MASTER="--master=http://node-1:8080" | ||
+ | </code> | ||
+ | * /etc/kubernetes/apiserver<code> | ||
+ | KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" | ||
+ | KUBE_ETCD_SERVERS="--etcd-servers=http://node-1:2379" | ||
+ | KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" | ||
+ | KUBE_API_ARGS="" | ||
+ | KUBE_API_PORT="--port=8080" | ||
+ | KUBELET_PORT="--kubelet-port=10250" | ||
+ | </code> | ||
+ | * /etc/controller-manager<code> | ||
+ | KUBE_CONTROLLER_MANAGER_ARGS="" | ||
+ | </code> | ||
+ | * /etc/scheduler<code> | ||
+ | KUBE_SCHEDULER_ARGS="" | ||
+ | </code> | ||
+ | * /etc/kubernetes/kubelet<code> | ||
+ | KUBELET_ADDRESS="--address=0.0.0.0" | ||
+ | KUBELET_HOSTNAME="--hostname-override=node-2" | ||
+ | KUBELET_API_SERVER="--api-servers=http://node-1:8080" | ||
+ | KUBELET_ARGS="" | ||
+ | KUBELET_PORT="--port=10250" | ||
+ | </code> | ||
+ | * /etc/kubernetes/proxy<code> | ||
+ | KUBE_PROXY_ARGS="" | ||
+ | </code> | ||
+ | * /etc/sysconfig/flanneld<code> | ||
+ | FLANNEL_ETCD_ENDPOINTS="http://node-1:2379" | ||
+ | FLANNEL_ETCD_PREFIX="/kube-centos/network" | ||
+ | FLANNEL_OPTIONS="-iface=eth1" | ||
+ | </code> | ||
+ | * manual step to configure flannel with etcd<code> | ||
+ | # systemctl start etcd | ||
+ | # etcdctl mkdir /kube-centos/network | ||
+ | # etcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }" | ||
+ | </code> | ||
+ | == service processes == | ||
+ | * master<code> | ||
+ | /usr/bin/etcd --name=default --data-dir=/var/lib/etcd/default.etcd --listen-client-urls=http://localhost:2379,http://node-1:2379 | ||
+ | usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://node-1:2379 --insecure-bind-address=0.0.0.0 --port=8080 --kubelet-port=10250 --allow-privileged=false --service-cluster-ip-range=10.254.0.0/16 | ||
+ | /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=http://node-1:8080 | ||
+ | /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=http://node-1:8080 | ||
+ | /usr/bin/flanneld -etcd-endpoints=http://node-1:2379 -etcd-prefix=/kube-centos/network -iface=eth1 | ||
+ | </code> | ||
+ | * nodes<code> | ||
+ | /usr/bin/kubelet --logtostderr=true --v=0 --api-servers=http://node-1:8080 --address=0.0.0.0 --port=10250 --hostname-override=node-2 --allow-privileged=false | ||
+ | /usr/bin/kube-proxy --logtostderr=true --v=0 --master=http://node-1:8080 | ||
+ | /usr/bin/flanneld -etcd-endpoints=http://node-1:2379 -etcd-prefix=/kube-centos/network -iface=eth1 | ||
+ | </code> | ||
- | Ports | + | == First pod - Hello Kubernetes! == |
- | * etcd: 2379 | + | |
- | * kube-apiserver: 8080 | + | |
- | * kubelet: 10250 | + | |
- | + | ||
- | + | ||
- | First pod | + | |
<code> | <code> | ||
- | $ kubectl run hello-node --image=gcr.io/google-samples/node-hello:1.0 --port=8080 | + | $ kubectl run node-hello --image=gcr.io/google-samples/node-hello:1.0 --port=8080 |
- | $ kubectl get deployment hello-node | + | $ kubectl get deploy |
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE | NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE | ||
- | hello-node 1 1 1 1 2d | + | node-hello 1 1 1 1 1h |
- | $ kubectl get pods | + | $ kubectl get po |
NAME READY STATUS RESTARTS AGE | NAME READY STATUS RESTARTS AGE | ||
- | hello-node-3526609615-5slx8 1/1 Running 0 2d | + | node-hello-3526609615-fqf4k 1/1 Running 0 1h |
- | $ kubectl expose deployment hello-node | ||
- | $ kubectl get service hello-node | + | $ kubectl expose deploy/node-hello --type=NodePort |
- | NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE | + | service "node-hello" exposed |
- | hello-node 10.254.65.168 <nodes> 8080:32260/TCP 2d | + | |
- | $ kubectl get pods --selector="run=hello-node" --output=wide | + | $ kubectl get svc -l run=node-hello |
- | NAME READY STATUS RESTARTS AGE IP NODE | + | NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
- | hello-node-3526609615-5slx8 1/1 Running 0 2d 172.30.65.2 node-2 | + | hello-node 10.254.139.8 <nodes> 8080:30881/TCP 11s |
- | $ curl http://node-2:32260 | + | $ kubectl get po -l run=node-hello -o wide |
+ | NAME READY STATUS RESTARTS AGE IP NODE | ||
+ | node-hello-3526609615-fqf4k 1/1 Running 0 1h 172.30.5.2 node-3 | ||
+ | |||
+ | $ curl http://node-3:30881 | ||
Hello Kubernetes! | Hello Kubernetes! | ||
+ | |||
+ | $ curl http://node-2:30881 | ||
+ | Hello Kubernetes! | ||
+ | |||
+ | |||
+ | </code> | ||
+ | |||
+ | == 2nd pod with replicas == | ||
+ | <code> | ||
+ | $ kubectl run kubernetes-bootcamp --image=jocatalin/kubernetes-bootcamp:v1 --port=8080 | ||
+ | deployment "kubernetes-bootcamp" created | ||
+ | |||
+ | $ kubectl get deploy | ||
+ | NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE | ||
+ | kubernetes-bootcamp 1 1 1 1 16s | ||
+ | |||
+ | |||
+ | $ kubectl get po | ||
+ | NAME READY STATUS RESTARTS AGE | ||
+ | kubernetes-bootcamp-2019480069-jtswf 1/1 Running 0 18s | ||
+ | |||
+ | $ kubectl expose deploy/kubernetes-bootcamp --type=NodePort | ||
+ | service "kubernetes-bootcamp" exposed | ||
+ | |||
+ | $ kubectl get svc | ||
+ | NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
+ | kubernetes 10.254.0.1 <none> 443/TCP 1h | ||
+ | kubernetes-bootcamp 10.254.195.177 <nodes> 8080:32693/TCP 13s | ||
+ | |||
+ | $ kubectl get po -o wide | ||
+ | NAME READY STATUS RESTARTS AGE IP NODE | ||
+ | kubernetes-bootcamp-2019480069-jtswf 1/1 Running 0 1m 172.30.93.2 node-2 | ||
+ | |||
+ | $ curl http://node-2:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-jtswf | v=1 | ||
+ | $ curl http://node-2:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-jtswf | v=1 | ||
+ | $ kubectl logs kubernetes-bootcamp-2019480069-jtswf | ||
+ | Kubernetes Bootcamp App Started At: 2017-04-04T19:45:42.811Z | Running On: kubernetes-bootcamp-2019480069-jtswf | ||
+ | Running On: kubernetes-bootcamp-2019480069-jtswf | Total Requests: 1 | App Uptime: 112.899 seconds | Log Time: 2017-04-04T19:47:35.710Z | ||
+ | Running On: kubernetes-bootcamp-2019480069-jtswf | Total Requests: 2 | App Uptime: 127.612 seconds | Log Time: 2017-04-04T19:47:50.423Z | ||
+ | |||
+ | $ kubectl scale deploy/kubernetes-bootcamp --replicas=4 | ||
+ | deployment "kubernetes-bootcamp" scaled | ||
+ | |||
+ | $ kubectl get po -o wide | ||
+ | NAME READY STATUS RESTARTS AGE IP NODE | ||
+ | kubernetes-bootcamp-2019480069-220qd 1/1 Running 0 57m 172.30.5.3 node-3 | ||
+ | kubernetes-bootcamp-2019480069-ftzgl 1/1 Running 0 57m 172.30.5.2 node-3 | ||
+ | kubernetes-bootcamp-2019480069-jtswf 1/1 Running 0 59m 172.30.93.2 node-2 | ||
+ | kubernetes-bootcamp-2019480069-k0gkq 1/1 Running 0 57m 172.30.93.3 node-2 | ||
+ | |||
+ | $ curl http://node-2:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-ftzgl | v=1 | ||
+ | $ curl http://node-3:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-220qd | v=1 | ||
+ | $ curl http://node-3:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-k0gkq | v=1 | ||
+ | $ curl http://node-2:32693 | ||
+ | Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-2019480069-jtswf | v=1 | ||
</code> | </code> |