When we setup Kubernetes cluster, we get a token and kubeadm join command using which we can add nodes to our Kubernetes cluster. If we want to add new worker node to scale up the Kubernetes cluster or if we have some issues with the existing node and we want to rejoin the node with the cluster, we can use below process to generate a new token and join command to rejoin or add worker node.
Create a Kubernetes new token and join command
We will first check the Kubernetes cluster status using below command on the master node.
# systemctl status kubelet
Since Kubernetes service is UP and working fine. We will generate a new token using kubeadm.
#kubeadm token generate
Once we have generated the new token, we will use the token to get the join command required for adding existing worker node or new worker node to the Kubernetes cluster.
# kubeadm token create 4q67v3.4rtnq4kwo00pch67 --print-join-command
--print-join-command will print the join command which can be executed directly on the worker node
We have successfully generated the join command required for adding the node to the Kubernetes cluster.
# kubeadm join 192.168.136.133:6443 --token 4q67v3.4rtnq4kwo00pch67 --discovery-token-ca-cert-hash sha256:48d8d287a67580043ae248fbcc9833cda72417ad597a87373323dbee3cdf7174
Execute Kubernetes new token and join command on worker nodes
Now we will copy the above join command and execute on the worker node.
Worker node has now been added to the kubernetes cluster. We can run same command on all our worker nodes which needs to be added to the kubernetes cluster. Now we can check and verify all the worker nodes from our Kubernetes master node.
# kubectl get nodes
We can also check the kubernetes control plane pods status using below command. Kubernetes can be explored from here.
# kubectl get pods -n kube-system
Conclusion
We have successfully created a Kubernetes new token and join command to rejoin/add worker node to the kubernetes cluster. We have also verified the overall health of the kubernetes cluster. You can learn how to deploy sample application on kubernetes by referring nginx.
Happy Learning😊