In this Kubernetes tutorial you will learn to drain a node using kubectl drain command to prepare for maintenance.
It is as simple as entering this command.
You can get the nodes details using kubectl get nodes command.
But there is more to draining nodes in Kubernetes so let8217s take a detailed look at it.
Kubernetes is designed to be fault tolerant of worker node failures. .
There might be different reasons a worker node becomes unusable such as because of a hardware problem a cloud provider problem or if there are network issues between worker and master node the Kubernetes master handles it effectively. .
But that doesnt mean it will always be the case. And this is when you need to drain the nodes and remove all the pods.
The draining is the process for safely evicting all the pods from a node. This way the containers running on the pod terminate gracefully.