❤️ ABS is one of the five Certified Kubernetes Service Providers in India ❤️

Managing Nodes in k8s - Join , Cordon , Drain

In this blog post, we will explore essential node management operations, including joining nodes, creating nodes, deleting nodes, and cordoning nodes.

Synopsis:
  • Joining Nodes
  • Cordoning Nodes
  • Draining Nodes
Joining Nodes to a Kubernetes Cluster
  1. Log in to the master node of your Kubernetes cluster where you have kubeadm installed.
  2. Use the kubeadm token create command to generate a new token. You can optionally set an expiration time for the token.
				
					kubeadm token create --print-join-command 

				
			

     3. The generated token and the associated join command allow worker nodes to securely join the Kubernetes cluster

				
					
#Replace with your node and port
kubeadm join --token token master-node-ip:port
				
			
Deleting Nodes in Kubernetes

Use the kubectl delete node command to delete the node.

				
					kubectl delete node node-name

				
			
Cordoning and Draining Nodes

To prevent new pods from being scheduled on a node, run the following command:

				
					kubectl cordon node-name

				
			

To safely evict existing pods from the node, use the kubectl drain command:

				
					kubectl drain node-name --force --ignore-daemonsets

				
			

Whether you need to join, create, delete, or cordon nodes, these operations are essential for scaling and maintaining your containerized applications. Feel free to refer k8s official docs: https://kubernetes.io/docs/home/