Adding Linux worker nodes

This page explains how to add Linux worker nodes to a kubeadm cluster.

Before you begin

Adding Linux worker nodes

To add new Linux worker nodes to your cluster do the following for each machine:

  1. Connect to the machine by using SSH or another method.
  2. Run the command that was output by kubeadm init. For example:
  1. sudo kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash>

Additional information for kubeadm join

Note:

To specify an IPv6 tuple for <control-plane-host>:<control-plane-port>, IPv6 address must be enclosed in square brackets, for example: [2001:db8::101]:2073.

If you do not have the token, you can get it by running the following command on the control plane node:

  1. # Run this on a control plane node
  2. sudo kubeadm token list

The output is similar to this:

  1. TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS
  2. 8ewj1p.9r9hcjoqgajrj4gi 23h 2018-06-12T02:51:28Z authentication, The default bootstrap system:
  3. signing token generated by bootstrappers:
  4. 'kubeadm init'. kubeadm:
  5. default-node-token

By default, node join tokens expire after 24 hours. If you are joining a node to the cluster after the current token has expired, you can create a new token by running the following command on the control plane node:

  1. # Run this on a control plane node
  2. sudo kubeadm token create

The output is similar to this:

  1. 5didvk.d09sbcov8ph2amjw

If you don’t have the value of --discovery-token-ca-cert-hash, you can get it by running the following commands on the control plane node:

  1. # Run this on a control plane node
  2. sudo cat /etc/kubernetes/pki/ca.crt | openssl x509 -pubkey | openssl rsa -pubin -outform der 2>/dev/null | \
  3. openssl dgst -sha256 -hex | sed 's/^.* //'

The output is similar to:

  1. 8cb2de97839780a412b93877f8507ad6c94f73add17d5d7058e91741c9d5ec78

The output of the kubeadm join command should look something like:

  1. [preflight] Running pre-flight checks
  2. ... (log output of join workflow) ...
  3. Node join complete:
  4. * Certificate signing request sent to control-plane and response
  5. received.
  6. * Kubelet informed of new secure connection details.
  7. Run 'kubectl get nodes' on control-plane to see this machine join.

A few seconds later, you should notice this node in the output from kubectl get nodes. (for example, run kubectl on a control plane node).

Note:

As the cluster nodes are usually initialized sequentially, the CoreDNS Pods are likely to all run on the first control plane node. To provide higher availability, please rebalance the CoreDNS Pods with kubectl -n kube-system rollout restart deployment coredns after at least one new node is joined.

What’s next