Kubectl drain is a command used to safely remove a node from the Kubernetes cluster. When a node is drained, all of the running pods are evicted and rescheduled onto other nodes in the cluster. This process ensures that no application downtime occurs during node maintenance or updates.
The kubectl drain command performs the following steps:
- Marks the node as unschedulable, preventing new pods from being scheduled on it.
- Evicts all existing pods from the node, ensuring they are gracefully terminated.
- Waits for all pods to be deleted before proceeding.
- Removes the node from the Kubernetes cluster.
Once you have completed maintenance on a node, you can use kubectl uncordon to make it schedulable again and allow new pods to be scheduled on it.




