# kubectl drain --force: Usage, Options & Common CI Errors

> kubectl drain --force evicts pods including unmanaged bare pods. The DaemonSet and local-data flags, the PDB block, and what --force actually risks.

Source: https://latchkey.dev/learn/command-reference/kubectl-drain-force  
Updated: 2026-06-25

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

```Terminal
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-5
```

## Common 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.

## Using this in CI

A runner has no kubeconfig, no cached context, and no interactive auth. Every kubectl invocation in CI needs the context supplied explicitly, and most confusing CI failures here are the command running against the wrong cluster or no cluster at all.

```Terminal
# never rely on the ambient context on a runner
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get pods

# confirm what you are actually connected to before mutating anything
kubectl config current-context
kubectl cluster-info

# fail fast instead of hanging on an unreachable API server
kubectl --request-timeout=30s get nodes
```

> Always set `--request-timeout` in CI. Without it an unreachable API server hangs until the job times out, which turns a thirty-second failure into a twenty-minute one.

## FAQ

### kubectl drain --force: Usage, Options & Common CI Errors?

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 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
