Install Kubernetes


kubernetes-architecture

Above is the Kubernetes design architecture. In my POC environment, I have written a script to install and configure the kubernetes. I have tested it on the RHEL 7, I think it should work on CentOS 7 as well but have not tested yet.

Please be aware that the script uses the latest codes from kubernetes git repo. The script may not work due to changes in the future, for exmaple deprecated paramters. But I will try to keep it up to date.

What it does?

1) Install docker, which is the fundamental container application. The script uses zzdocker0 to replace the default bridge docker0, as some applications (e.g facter) uses the first non 127.x.x.x IP address as the primary IP address of the host.

2) Install flannel, which provides the backend overlay network. It allows the communication between containers on different hosts.

3) Install etcd on master, which is a distributed key value store. It is for shared configuration and service discovery.

4) Install Kubernetes master components: kube-apiserver, kube-controller-manager, kube-scheduler

5) Install Kubernetes node components:  kubelet, kube-proxy

How to use?

For master:
1) wget https://raw.githubusercontent.com/jc1518/docker/master/kubernetes/scripts/kube-master.sh
2) Define master IP address, and proxy if needed.
3) chmod a+x kube-master.sh
4) ./kube-master.sh

For node:
1) wget https://raw.githubusercontent.com/jc1518/docker/master/kubernetes/scripts/kube-node.sh
2) Define master IP address, and proxy if needed.
3) chmod a+x kube-node.sh
4) ./kube-node.sh

What it looks like?

Here is my environment.
dockerdev01: node
dockerdev02: both master and node

[root@dockerdev02 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)

[root@dockerdev02 ~]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.1.12  netmask 255.255.255.0  broadcast 192.168.1.255
ether 00:50:56:8c:41:4e  txqueuelen 1000  (Ethernet)
RX packets 532380  bytes 543278948 (518.1 MiB)
RX errors 0  dropped 607  overruns 0  frame 0
TX packets 237001  bytes 75318928 (71.8 MiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
inet 172.16.100.0  netmask 255.255.0.0  broadcast 0.0.0.0
ether ea:d8:1f:bb:1a:2d  txqueuelen 0  (Ethernet)
RX packets 0  bytes 0 (0.0 B)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 0  bytes 0 (0.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
loop  txqueuelen 0  (Local Loopback)
RX packets 481545  bytes 44838800 (42.7 MiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 481545  bytes 44838800 (42.7 MiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

zzdocker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 172.16.100.1  netmask 255.255.255.0  broadcast 0.0.0.0
ether 3e:7f:06:e2:da:53  txqueuelen 0  (Ethernet)
RX packets 0  bytes 0 (0.0 B)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 2  bytes 84 (84.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@dockerdev02 ~]# kubectl.sh get nodes
NAME                    LABELS                                         STATUS
dockerdev01.dmz.local   kubernetes.io/hostname=dockerdev01.dmz.local   Ready
dockerdev02.dmz.local   kubernetes.io/hostname=dockerdev02.dmz.local   Ready

[root@dockerdev02 ~]# kubectl.sh get pods
POD       IP        CONTAINER(S)   IMAGE(S)   HOST      LABELS    STATUS    CREATED   MESSAGE

[root@dockerdev02 ~]# kubectl.sh get svc
NAME            LABELS                                    SELECTOR   IP(S)        PORT(S)
kubernetes      component=apiserver,provider=kubernetes   <none>     172.16.0.2   443/TCP
kubernetes-ro   component=apiserver,provider=kubernetes   <none>     172.16.0.1   80/TCP

[root@dockerdev02 ~]# kubectl.sh get rc
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR   REPLICAS

Advertisements

2 thoughts on “Install Kubernetes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s