DEV Community

Atsushi Suzuki
Atsushi Suzuki

Posted on

Kubernetest (on-prem) master node and worker node associations.

Procedure for reassociating worker nodes with the master node in on-premise Kubernetes after restarting the worker nodes.
++++++++++++++++++++++++++++++++
[Environment]
Ubuntu 20.10
Cluster Version 1.22.2
++++++++++++++++++++++++++++++++

1) Reset the state of kubelet using kubeadm. (on the worker node)

$ kubeadm reset
Enter fullscreen mode Exit fullscreen mode

2) Generate the --discovery-token-ca-cert-hash (on the master node)

$ openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
Enter fullscreen mode Exit fullscreen mode

Paste the output hash into a notepad for later use.

3) Generate a --token (on the master node)

$ kubeadm token create
Enter fullscreen mode Exit fullscreen mode

Copy and paste the output token into a notepad.

4) Reassociate with the master node (on the worker node)

Use the values output in steps 2) and 3).

kubeadm join [Master Node IP]:6443 --token [token created on master node] --discovery-token-ca-cert-hash sha256:[hash value created on master node]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)