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:
- To add new worker node to your cluster, do the following for each new machine:
- SSH to the machine
- Become root (for example
sudo su -) - 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>
- If you do not have the token, you can get it by running the following command on the
control-plane node:
-
kubeadm token listOutput 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 - 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 createThe output will be similar as given below:5didvk.d09sbcov8ph2amjw - 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
-