Step 8 - Install kubernetes
Now after adding the kubernetes repo we need to install the kubernetes on both mater as well as worker node
1sudo apt-get update && sudo apt-get install -y kubelet kubeadm kubectl
Step 9 - Enable and Start kubelet
Alright now we have installed the kubernetes, now we need to enable the kubelet support for both master as well worker node
1sudo systemctl enable kubelet
1sudo systemctl start kubelet
Step 10 - Initialize the kubernetes cluster
Okay now we have reach to point where we have done all the prerequisite for initializing the kubernetes cluster.
Let's run the kubernetes initialization command on only on master
1sudo kubeadm init --apiserver-advertise-address=100.0.0.1
Note down kubeadm join command which we are going to use from worker node to join the master node using token. (Note : - Followig command will be different for you, do not try copy the following command)
1sudo kubeadm join 100.0.0.1:6443 --token g2bsw7.5xr3bqc21eqyc6r7 --discovery-token-ca-cert-hash sha256:39b2b0608b9300b3342a8d0a0e9204c8fc74d45b008043a810f94e4f1fb8861f
Step 11 - Move kube config file to current user (only run on master)
To interact with the kubernetes cluster and to user kubectl command, we need to have the kube config file with us.
Use the following command to get the kube config file and put it under working directory.
1mkdir -p $HOME/.kube
1sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
1sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step 12 - Apply CNI from kube-flannel.yml(only run on master)
After the master of the cluster is ready to handle jobs and the services are running, for the purpose of making containers accessible to each other through networking, we need to set up the network for container communication.
Get the CNI(container network interface) configuration from flannel
1wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Step 13 - Join worker nodes to master(only run on worker)
In the Step 10 we generated the token and kubeadm join command.
Now we need to use that join command from our worker node
Comments