Before You Drain a Node: How to Check Impact in Kubernetes
Before draining a Kubernetes node, list the pods on it, find which have a single replica or no PodDisruptionBudget, and check whether other nodes have the capacity to reschedule them.
kubectl drain cordons a node and evicts its pods. Whether that is safe depends on three things you can check beforehand.
1. What is running there
kubectl get pods -A -o wide --field-selector spec.nodeName=NODE_NAME
Ignore DaemonSet pods; kubectl drain --ignore-daemonsets handles them. Focus on the rest.
2. How resilient each workload is
For every owner of those pods, check:
- Replicas: with one replica there will be a gap while the new pod starts.
- PodDisruptionBudget:
kubectl get pdb -A. A PDB withminAvailable: 1on a one-replica Deployment will block the drain. - Spread: if all replicas are on this node, you lose them all at once. Look at topology spread constraints and anti-affinity.
3. Whether there is somewhere to go
Pods need schedulable capacity elsewhere, and any nodeSelector, taints or volume zone constraints must be satisfiable. A pod bound to a zonal volume can only move within that zone.
Unplanned loss is different
If a node dies rather than being drained, pods are not evicted gracefully. By default they are marked for eviction after a 300 second toleration of the not-ready and unreachable taints, so single-replica workloads can be down for minutes.
Automating the check
Kubilitics adds Pod-to-Node scheduling edges to its dependency graph, so selecting a Node shows exactly which workloads would be lost, and which of them are single points of failure. See blast radius analysis.
Frequently asked questions
Why does kubectl drain hang?
Usually a PodDisruptionBudget would be violated by evicting a pod, for example minAvailable: 1 on a one-replica Deployment. The eviction is retried until the budget allows it.
What happens to a single-replica pod on a drained node?
It is evicted and rescheduled elsewhere. The Service has no healthy backend between eviction and the new pod becoming ready.