Horizontal Scaling in Kubernetes Cluster

Horizontal scaling can be achieved in the Kubernetes cluster by adding new worker nodes to the cluster.

New worker nodes can be added to an existing cluster when resources of current worker nodes are utilized. Follow below steps to join a worker node to master node:
  1. To add new worker node to your cluster, do the following for each new machine:
    1. SSH to the machine
    2. Become root (for example sudo su -)
    3. Run the command that was output by kubeadm init. For example: kubeadm join --token <token> <control-plane-host>:<control-plane port> --discovery-token-ca-cert-hash sha256:<hash>
  2. If you do not have the token, you can get it by running the following command on the control-plane node:
    1. kubeadm token list

      Output will be similar as given below:

         TOKEN                           TTL  		EXPIRES              USAGES            DESCRIPTION          EXTRA GROUPS
      8ewj1p.9r9hcjoqgajrj4gi            23h        2018-06-12T02:51:28Z   authentication,signing     <none>     system:bootstrappers:kubeadm:default-node-token 
      
    2. By default, 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:
      kubeadm token create
      The output will be similar as given below:
      5didvk.d09sbcov8ph2amjw
    3. If you do not have the value of --discovery-token-ca-cert-hash, you can get it by running the following command chain on the control-plane node:
      openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \openssl dgst -sha256 -hex | sed 's/^.* //'
      
      The output will be similar as given below:
      8cb2de97839780a412b93877f8507ad6c94f73add17d5d7058e91741c9d5ec78