KubeErrors

cannot delete DaemonSet-managed Pods: kubectl drain refuses to proceed because DaemonSet pods cannot be evicted

DaemonSet pods would be recreated on the same node immediately, so drain refuses to evict them without an explicit flag. The same applies to pods with local storage and to unmanaged pods.

Applies to: All Kubernetes versions

What it means

kubectl drain evicts pods from a node so it can be taken out of service, and it refuses categories of pod where eviction would be futile or destructive. DaemonSet pods are futile — the controller would immediately recreate them on the same node, since that is what a DaemonSet does. Pods using emptyDir are potentially destructive, because that data is node-local and evicting the pod destroys it. And pods with no controller are unrecoverable, since nothing would recreate them elsewhere. Each has its own flag, and each flag is an acknowledgement of a specific consequence rather than a formality.

Most common causes

How to diagnose it

  1. Read which category the message names — the flag needed differs per category.
  2. List the pods on the node with their owners: kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=NODE.
  3. Check for pods with no owner references, which are the unmanaged ones.
  4. Check whether any pod uses emptyDir and whether that data matters.
  5. Check disruption budgets separately, since a PDB block is a different refusal with different implications.

How to fix it

  1. Use --ignore-daemonsets, which is standard practice for any drain. DaemonSet pods stay and are removed when the node is deleted.
  2. Use --delete-emptydir-data only after confirming the data is genuinely disposable. The flag's name is the warning.
  3. Use --force for unmanaged pods, understanding that they are deleted permanently and nothing will recreate them.
  4. Resolve PodDisruptionBudget blocks by making the budget satisfiable rather than by bypassing it.
  5. Script the drain with the flags your environment needs, so the decision is made once and deliberately rather than under time pressure.

Notes

--delete-emptydir-data is the flag worth pausing on. Caches and scratch space are fine to lose; a workload keeping state in an emptyDir because it seemed convenient is not, and drain is the moment that becomes apparent.

Related

Sources

Pages on this site are written with AI assistance from the primary sources listed on each page, then checked against those sources before publishing.