How to Add Workers to Kubernetes Clusters

When a Kubernetes cluster is first initialized a token used to add workers is generated. Tokens only have a lifespan of 24-hours, preventing you from adding additional nodes after that time limit.

In this tutorial I will show you how to manage your tokens, allowing you to add more workers to an existing cluster.

Managing your Cluster’s Tokens

  1. Using the kubeadm command, list your current tokens. If more than 24-hours has passed since the cluster was initialized, the list will likely be empty.

Creating a New Token

  1. Using the kubeadm command, list your current tokens on the Master node. If your cluster was initialized over 24-hour ago, the list will likely be empty, since a token’s lifespan is only 24-hours.
    kubeadm tokens list
  2. Create a new token using kubeadm. By using the –print-join-command argument kubeadm will output the token and SHA hash required to securely communicate with the master.
    kubeadm token create --print-join-command
  3. Use kubeadm to list all tokens in order to verify our new one.
    kubeadm tokens list

Joining the New Worker to the Cluster

With our new token in hand it is time to join our worker to the cluster.

  1. Using SSH, log onto the new worker node.
  2. Use the kubeadm join command with our new token to join the node to our cluster.
    kubeadm join --token qt57zu.wuvqh64un13trr7x --discovery-token-ca-cert-hash sha256:5ad014cad868fdfe9388d5b33796cf40fc1e8c2b3dccaebff0b066a0532e8723
  3. List your cluster’s nodes to verify your new worker has successfully joined the cluster.
    kubectl get nodes
  4. Verify that the worker’s status to ensure no problems were encountered.
    kubectl get nodes my-worker-name