Kubernetes — Create a new token and join command to rejoin/add worker node

Monowar Mukul
3 min readAug 24, 2020

--

In this tutorial, I will go through for creating a new token before adding a node to the Kubernetes cluster.

When we initialize Kubernetes on Master node using “kubeadm init”, at the bottom section it presents the node join command which includes a token and a hash.

Kube init output — initial part
Kube init output- end part

But these values stay valid for 24 hours. So if want to rejoin any worker node or want to add a new worker node we need to generate the join command again.

To setup the join command you can follow the below steps —

Kubernetes Master Node:

i) Check status —

systemctl status kubelet
Master Node — Kubectl status

ii) Generate a token

[root@devops ~]# kubeadm token generate
hp9b0k.1g9tqz8vkf78ucwf

iii) Generate node join command

Take the output value of the token and generate join command

[root@devops ~]# kubeadm token create hp9b0k.1g9tqz8vkf78ucwf --print-join-commandW1022 19:51:03.885049   26680 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
kubeadm join 192.168.56.110:6443 --token hp9b0k.1g9tqz8vkf78ucwf --discovery-token-ca-cert-hash sha256:32eb67948d72ba99aac9b5bb0305d66a48f43b0798cb2df99c8b1c30708bdc2c

On Kubernetes Worker Node

Now copy the join command output from the Master node and execute that to the worker node.

kubeadm join 192.168.56.110:6443 --token hp9b0k.1g9tqz8vkf78ucwf     --discovery-token-ca-cert-hash sha256:32eb67948d72ba99aac9b5bb0305d66a48f43b0798cb2df99c8b1c30708bdc2c
Join command on worker node

Now validate from the Master node -

Node list

So the node has been joined successfully.

I hope you know how to add nodes to the Kubernetes cluster master node. Thank you.

Reference:

https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-token/

Authors Bio

Monowar Mukul is currently working as a Principal Oracle Database Specialist. I am an Oracle Certified Master (Oracle 12c Certified Master Administration, Oracle 12c Certified Master MAA, and Oracle 11g Certified Master Administration). He has been working as an Oracle DBA consultant over 17 years with Oracle MAA space for both Exadata and non-Exadata Systems, Oracle Cloud Space, and SOA Middleware. He is working with different devops tools over four years. You can find more details about him and his work achievements at https://www.linkedin.com/in/monowarmukul/

--

--

Monowar Mukul
Monowar Mukul

Written by Monowar Mukul

Monowar Mukul is a Cloud Solution Architect Professional. /*The statements and opinions expressed here are my own & nothing with my present or past employer*/

No responses yet