kubectl drain --force: Usage, Options & Common CI Errors
Drain a node even when it runs unmanaged or local-storage pods.
kubectl drain --force evicts a node's pods including bare pods not backed by a controller, which a plain drain refuses to touch. With its companion flags it is how node-lifecycle automation empties a node before maintenance.
What it does
kubectl drain NODE cordons the node and evicts its pods via the eviction API, honouring PodDisruptionBudgets. --force additionally deletes unmanaged ("naked") pods that would otherwise block the drain. --ignore-daemonsets skips DaemonSet pods, and --delete-emptydir-data permits evicting pods with emptyDir local data (which is lost).
Common usage
kubectl drain ip-10-0-1-5 --ignore-daemonsets --delete-emptydir-data
kubectl drain ip-10-0-1-5 --force --ignore-daemonsets
kubectl drain ip-10-0-1-5 --grace-period=120 --timeout=5m --ignore-daemonsets
# ... maintenance ...
kubectl uncordon ip-10-0-1-5Common errors in CI
"cannot delete Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet" needs --force - but understand --force here means those bare pods are deleted and not rescheduled anywhere, so they are simply gone. "cannot delete DaemonSet-managed Pods" needs --ignore-daemonsets; "cannot delete Pods with local storage" needs --delete-emptydir-data (the data is destroyed). The blocker that hangs automation is a PodDisruptionBudget: "Cannot evict pod ... violates the disruption budget" makes drain retry until another replica is Ready - set --timeout so the step fails instead of hanging.