Skip to content

Configure Worker Nodes

In this section, we will set up worker VMs and join them to the k8s cluster we created in the previous step. You have to repeat this procedure for every node, which in our environment are nodes kubernetes-worker1, kubernetes-worker2, and kubernetes-worker3.

Prepare worker VM

SSH to kubernetes-workerX VM and follow instructions to prepare it for kubernetes.

Refresh cluster token

The cluster token generated by kubeadm in the previous section expires after a certain time. You will need to regenerate it before you can join another node to the cluster.

Log in to the kubernetes-master node and run the following command:

kubeadm token create

The command will return a new cluster token, which you will use in the next step.

Note

By contrast with the cluster token, the discovery token doesn't change through the lifetime of the cluster. You can use the discovery token that was printed out by kubeadm init in the next command.

Join worker node to the cluster

SSH into kubernetes-workerX node and run command to join it to the cluster:

Network

If necessary, update the following command with the IP address of the kubernetes master node specific to your environment.

sudo kubeadm join 10.0.0.221:6443 --token <NEW_TOKEN> \
  --discovery-token-ca-cert-hash <DISCOVERY_TOKEN>

If everything went successfully, the command will return the message This node has joined the cluster.

Validation

SSH into kubernetes-master and confirm that the new worker node is part of the cluster:

kubectl get nodes

You should see all nodes configured so far, i.e.:

NAME                 STATUS   ROLES                  AGE   VERSION
kubernetes-master    Ready    control-plane,master   50m   v1.22.3
kubernetes-worker1   Ready    <none>                 30m   v1.22.3
kubernetes-worker2   Ready    <none>                 20m   v1.22.3
kubernetes-worker3   Ready    <none>                 10m   v1.22.3