Disruptions, drains and PodDisruptionBudgets
Voluntary and involuntary disruptions, how kubectl drain uses the Eviction API, how PodDisruptionBudgets refuse evictions, and the traps.
Disruptions, drains and PodDisruptionBudgets
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Involuntary disruptions (hardware failure, kernel panic, node out of resources) just happen. Voluntary ones (drains for upgrades, autoscaler scale-down) are chosen, and can be paced.
- kubectl drain cordons the node, then evicts each Pod through the Eviction API, retrying while the API refuses. kubectl delete pod skips that check entirely.
- A PodDisruptionBudget sets minAvailable or maxUnavailable for Pods matching a selector. The disruption controller turns it into disruptionsAllowed, and evictions beyond it get 429 Too Many Requests.
- Only Ready Pods count as healthy. A rollout or crash that leaves replacements unready blocks drains, and unhealthyPodEvictionPolicy AlwaysAllow lets stuck unhealthy Pods be evicted anyway.
- A budget that can never be met (maxUnavailable 0, or minAvailable 1 on a single replica) blocks every drain, node upgrade and autoscaler scale-down until someone intervenes.
Pods get moved all the time
A Pod isn’t forever. Nodes are upgraded, patched, resized and removed. A cluster autoscaler empties underused nodes to save money. Spot instances are reclaimed. Each of these moves Pods, and if they move all at once, a perfectly replicated service can still go down: four replicas on four nodes is no help if an upgrade drains all four nodes at the same moment.
Kubernetes separates two kinds of disruption. Involuntary ones just happen: hardware fails, a VM vanishes, the kernel panics, a node runs out of memory. You defend against those by spreading replicas and by node failure handling. Voluntary ones are actions someone or something chose to take, and those can be paced. The tool for pacing them is the PodDisruptionBudget, and the path that respects it is the Eviction API.
Drain = cordon + evict
kubectl drain is the standard way to empty a node:
kubectl drain n1 --ignore-daemonsets --delete-emptydir-data
# ... maintenance ...
kubectl uncordon n1
It does two things. It cordons the node (spec.unschedulable: true, shown as SchedulingDisabled) so nothing new lands there. Then it evicts each Pod by creating an Eviction object for it, rather than deleting it. An eviction is a request: the API server checks the PodDisruptionBudgets covering the Pod and either deletes it gracefully or refuses with 429 Too Many Requests. Drain retries refused evictions every five seconds until it succeeds or times out.
Drain also refuses some Pods outright. On our lab node with a bare Pod and one using an emptyDir, a server-side dry run said:
cannot delete Pods that declare no controller (use --force to override): sched/bare-1,
cannot delete Pods with local storage (use --delete-emptydir-data to override): sched/scratchy
A bare Pod evicted is gone for good. An emptyDir’s data dies with the Pod. DaemonSet Pods would be recreated on the same node at once, hence --ignore-daemonsets.
The cluster autoscaler, Karpenter and managed node upgrades on EKS, GKE and AKS all use evictions too. kubectl delete pod doesn’t: it bypasses budgets completely.
PodDisruptionBudgets
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata: {name: web, namespace: sched}
spec:
minAvailable: 3
selector: {matchLabels: {app: web}}
A PDB says how many Pods matching its selector must stay up during voluntary disruptions: minAvailable (a number or a percentage) or maxUnavailable, not both. Think of a restaurant manager’s rule during staff breaks: at least three waiters on the floor at all times. Anyone can ask for a break, and the manager says “not now” if it would leave two.
The disruption controller watches the Pods and keeps the PDB’s status current: currentHealthy (Ready Pods), desiredHealthy, and disruptionsAllowed. maxUnavailable is usually the better choice for Deployments, because it scales with the replica count and still allows one eviction at a time.
Watching it refuse
We ran a four-replica Deployment across four fake nodes in the lab. Nothing runs containers there, so we wrote each Pod’s Ready condition into its status ourselves, standing in for the kubelet. The disruption controller then reported ALLOWED DISRUPTIONS 1 for the budget above.
Draining n1 evicted its Pod at once. The ReplicaSet created a replacement on n3, and the budget dropped to disruptionsAllowed: 0 with reason InsufficientPods, because the replacement wasn’t Ready yet. Draining n2 straight away produced exactly the loop you see in real clusters:
evicting pod sched/web-689b9bdbdd-8x8cb
error when evicting pods/"web-689b9bdbdd-8x8cb" -n "sched" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
Once we marked the replacement Ready, disruptionsAllowed went back to 1 and the next eviction went through. That’s the whole design: drains proceed at the pace the application can absorb, as replacements become healthy. An eviction called directly through the API for a healthy Pod, while the budget was at 0, got the same answer as a status: TooManyRequests.
In the lab, evicted Pods stayed Terminating and drain waited for them until it timed out, because no kubelet was there to stop the containers. On a real node, they’d terminate within their grace period. The graceful shutdown lesson covers what happens inside the Pod.
Traps
Budgets that can never be met. maxUnavailable: 0, or minAvailable: 1 on a single-replica Deployment, means disruptionsAllowed is always 0. Every drain hangs, managed node upgrades stall or force through after a timeout, and the autoscaler can never remove that node. If an app can’t tolerate one Pod being moved, it needs more replicas, not a stricter budget.
Unhealthy Pods. Only Ready Pods count as healthy. A Deployment whose Pods are crash-looping can hold a budget below its floor forever, and with the default unhealthyPodEvictionPolicy: IfHealthyBudget, those broken Pods can only be evicted while the budget is otherwise met. Setting unhealthyPodEvictionPolicy: AlwaysAllow (GA in 1.31) lets unready Pods always be evicted, which unblocks drains without touching healthy capacity. It’s a sensible default for most stateless apps.
Overlapping selectors. If a Pod matches more than one PDB, eviction fails with an error rather than guessing. Keep one budget per workload.
Not a shield against everything. Preemption only tries to respect budgets, the node lifecycle controller’s NoExecute evictions ignore them, and involuntary failures obviously do too.
About the video
The embed is Drewbernetes’s “Kubernetes Pod Disruption Budgets | How to keep your workloads online during planned maintenance”, January 2024, 9 minutes. Its chapters cover a setup, a case study for why you should use PDBs, what one is, how to create one, maxUnavailable against minAvailable, and a drain in action. It doesn’t cover unhealthyPodEvictionPolicy or the never-satisfiable budget trap, which this lesson adds. Judged from chapters and description, since transcripts can’t be fetched here, and from its “English (US) original” audio track. It’s a small channel. Nirav Gandhi’s video in deeper starts from voluntary against involuntary disruptions.
What was run: against a local v1.37.3 control plane with four fake Nodes kept alive by a Lease-renewing script, we created a four-replica Deployment and the PDB above, marked Pods Ready by hand in place of a kubelet, drained one node, watched the real disruption controller drop disruptionsAllowed to 0 and kubectl drain retry on the PDB refusal, saw it proceed once the replacement was Ready, got a 429 from the Eviction API directly, and read drain’s refusal of bare and emptyDir Pods with a server-side dry run. Containers never ran, so termination itself is from the docs, checked 2026-11-29.
Where this fits
A budget counts Pods that are Ready, so everything in this lesson depends on readiness meaning something. Next: liveness, readiness and startup probes.
Check yourself
You drain a node and it hangs with 'Cannot evict pod as it would violate the pod's disruption budget' repeating every 5 seconds. What does that mean, and what should you check?
The PDB's disruptionsAllowed is 0, so the API refuses the eviction and kubectl drain retries. Check kubectl get pdb: often a replacement Pod elsewhere isn't Ready yet (wait), or the budget is impossible to meet, such as minAvailable equal to the replica count.
Does a PodDisruptionBudget stop a node from crashing and taking three of your four replicas with it?
No. PDBs only limit voluntary disruptions that go through the Eviction API. For involuntary ones you need replicas spread across nodes and zones, with topology spread constraints or anti-affinity.
Why does drain refuse a node with a bare Pod (no controller) or a Pod with an emptyDir unless you add flags?
Evicting a bare Pod deletes it forever, since nothing recreates it (--force to accept that). Evicting a Pod with emptyDir deletes that data (--delete-emptydir-data). DaemonSet Pods would be recreated on the same node at once, so they need --ignore-daemonsets.
A Deployment of 5 has a PDB with maxUnavailable 1. Two Pods are crash-looping and not Ready. Can a drain evict a healthy Pod? An unhealthy one?
Not a healthy one: three of five are healthy and the budget requires four. With the default unhealthyPodEvictionPolicy IfHealthyBudget, the unhealthy ones can't be evicted either while the budget isn't met. With AlwaysAllow, unready Pods can always be evicted, which unblocks the drain without touching healthy capacity.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.