User Tools

Site Tools


cloud:kubernetes:installation

This is an old revision of the document!


Basic installation

On Centos7, RPMs are from Ceontos7 extras repository

1 master, 2 nodes

RPM verisons
  • On master:
    • kubernetes-master, kubernetes-client - 1.5.2-0.2.gitc55cf2b.el7
    • etc - 3.1.0-2.el7
    • flannel - 0.7.0-1.el7
  • On nodes:
    • kubernetes-client, kubernetes-node - 1.5.2-0.2.gitc55cf2b.el7
Services
  • On master:
    • etcd
    • kube-apiserver
    • kube-controller-manager
    • kube-scheduler
    • flanneld
  • On nodes:
    • kubelet
    • kube-proxy
    • flanneld
configuration files
  • /etc/etcd/etcd.conf
    ETCD_NAME=default
    ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
    ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://node-1:2379"
    ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,http://node-1:2379"
  • /etc/kubernetes/config - for both master and node
    KUBE_LOGTOSTDERR="--logtostderr=true"
    KUBE_LOG_LEVEL="--v=0"
    KUBE_ALLOW_PRIV="--allow-privileged=false"
    KUBE_MASTER="--master=http://node-1:8080"
  • /etc/kubernetes/apiserver
    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"
  • /etc/controller-manager
    KUBE_CONTROLLER_MANAGER_ARGS=""
  • /etc/scheduler
    KUBE_SCHEDULER_ARGS=""
  • /etc/kubernetes/kubelet
    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"
  • /etc/kubernetes/proxy
    KUBE_PROXY_ARGS=""
  • /etc/sysconfig/flanneld
    FLANNEL_ETCD_ENDPOINTS="http://node-1:2379"
    FLANNEL_ETCD_PREFIX="/kube-centos/network"
  • manual step to configure flannel with etcd
    # 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\" } }"   
service processes
  • master
    /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
  • nodes
    /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
Hostnames, subnets, IP ranges
  • master and node IPs
    • master: node-1(192.168.50.101/24)
    • nodes: node2(192.168.50.102/24), node-3(192.168.50.103/24)
    • kubernetes cluster IP range: 10.254.0.0/16
    • flannel: 172.30.0.0/16, subnetLen:24, type: vxlan
Ports
  • etcd: 2379
  • kube-apiserver: 8080
  • kubelet: 10250
First pod
$ kubectl run hello-node --image=gcr.io/google-samples/node-hello:1.0 --port=8080

$ kubectl get deployment hello-node
NAME         DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hello-node   1         1         1            1           2d

$ kubectl get pods
NAME                          READY     STATUS    RESTARTS   AGE
hello-node-3526609615-5slx8   1/1       Running   0          2d

$ kubectl expose deployment hello-node --type=NodePort

$ kubectl get service hello-node
NAME         CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-node   10.254.65.168   <nodes>       8080:32260/TCP   2d

$ kubectl get pods --selector="run=hello-node" --output=wide
NAME                          READY     STATUS    RESTARTS   AGE       IP            NODE
hello-node-3526609615-5slx8   1/1       Running   0          2d        172.30.65.2   node-2

$ curl http://node-2:32260
Hello Kubernetes!
cloud/kubernetes/installation.1491247910.txt.gz · Last modified: 2017/04/03 12:31 by frank