Kubernetes Activity 1: To build basic Kubernetes cluster with one master and two worker nodes on ubuntu servers

Diagram to follow:

Infrastructure requirements for this activity:

3 Ubuntu 18.04 Bionic Beaver LTS of small 2 units tag it as

  1. Kube Master
  2. Kube Node 1
  3. Kube Node 2

a. Install docker on all the three servers in preparation for standing up a Kubernetes cluster.

  1. Add docker repository GPG key using the below command:

2. Add docker repository:

5.Prevent auto updates for the docker packages:

6 To check the docker is running for master and all the nodes:

Repeat the above set of steps on rest of the two worker nodes server as well to install the docker.

b.Install Kubeadm, Kubelet , Kubectl on all the three servers

  1. Add Kubernetes repository GPG key

2. Add kubernetes repository

3.Reload apt sources list

4.To install Kubernetes package

5.To prevent autoupdate of the kube package:

6.After installing these components, verify that Kubeadm is working by getting the version info.

Perform all the six steps to install Kubeadm, Kubelet , Kubectl on rest of the two servers as well.

c. Bootstrapping the cluster on the Kube master node. Then, joining each of the two worker nodes to the cluster, forming an actual multi-node Kubernetes cluster

  1. On the Kube master node, initialize the cluster.Special pod network setting is required for flannel networking plug-in.

sudo kubeadm init --pod-network-cidr=10.244.0.0/16

2. Set up kube config for local user on the kube master server.This will allow to use kubectl when log in into the master.

3. Verify that the cluster is responsive and that Kubectl is working ON THE MASTER.You should get Server Version as well as Client Version

4. The kubeadm init command should output a kubeadm join command containing a token and hash. Copy that command and run it with sudo on both worker nodes. It should look something like this with $some_ip , $some_hash, $some_token

On master node copy this join command and remove extra / and copy on worker node1 and 2 with sudo as prefix.

Master Kube

Work node 2

work node 1:

5.Run the below command from master node to verify that all nodes have successfully joined the cluster.

Note:* The nodes are expected to have a STATUS of NotReady at this point till the point networking is set up.

d. To configure cluster networking in order to make the cluster fully functional

Kubernetes provide variety of networking solution between the containers.One is called Flannel.

  1. On all three nodes, run the following for networking to work and turn on the networking bridge net.bridge.bridge-nf-call-iptables on all 3 nodes:

2. Install Flannel in the cluster by running this only on the Master node:

3.Verify that all the nodes now have a STATUS of Ready

Note:* It may take a few moments for all nodes to enter the Ready status, so if they are not all Ready, wait a few moments and try again.

4.To verify that the Flannel pods are up and running. You should have three pods with flannel in the name, and all three should have a status of Running.Run this command to get a list of system pods