Zero Labs
Industry News / AI

PodDisruptionBudget: The Safety Net Nobody Sets Up Until It’s Too Late

Source · Towards AI By Swapnil Ahire

From the publisher’s feed, collected in the ZeroLabs newsroom.

Self-healing brings a crashed Pod back. It does nothing to stop an administrator from politely draining every replica off a Node at the same time.Draining a Node for maintenance or a Kubernetes upgrade can take down every replica of a service at once — self-healing doesn’t stop this because it’s a voluntary, permitted disruption. Here’s how a PodDisruptionBudget prevents it, with working YAML examples.PodDisruptionBudget Explained — Protect Apps During Node Drains and UpgradesHere’s a scenario that catches even experienced administrators off guard: you’re doing exactly what you’re supposed to do — draining a Node for routine maintenance, or working through a Kubernetes version upgrade one Node at a time, following the documented process almost to the letter. And then every single replica of one particular service goes down at once, because it turns out all three of its Pods happened to be sitting on the one Node you just drained.Nothing crashed. Nothing failed in the sense the earlier self-healing article in this series covered. This wasn’t an accident Kubernetes needed to notice and recover from — it was a deliberate, permitted action that the cluster carried out exactly as instructed. And that’s precisely why self-healing didn’t save you here: self-healing responds to unexpected failures. This was an entirely voluntary one, requested by a human, following the rules correctly.The tool that closes this gap is called a PodDisruptionBudget — PDB for short — and if you’re running anything you actually care about staying available, it’s one of the more consequential objects you can define, precisely because it protects against a category of outage that has nothing to do with bugs or crashes at all.Self-healing protects you from Kubernetes noticing something went wrong. A PodDisruptionBudget protects you from Kubernetes correctly doing something you asked it to do, at the worst possible moment.Voluntary vs. Involuntary DisruptionsThis distinction is the entire foundation of why PDBs exist, so it’s worth being precise about it. Kubernetes separates Pod disruptions into two categories, and they’re handled completely differently.An involuntary disruption is something unexpected — a Node crashing, a hardware failure, the kubelet dying unexpectedly, an out-of-memory kill. These are exactly the failures the Deployment controller’s self-healing mechanism, covered earlier in this series, was built to respond to: notice the gap between desired and actual state, and close it automatically.A voluntary disruption is something deliberately initiated, through a legitimate, permitted action: an administrator running kubectl drain before Node maintenance, a cluster autoscaler scaling down and removing a Node it's decided is no longer needed, or a rolling update as part of a managed Kubernetes version upgrade. None of these are bugs. They're the system working correctly. And that's exactly the problem — self-healing has nothing to say about "correctly working as designed," because from Kubernetes's perspective, nothing has actually gone wrong yet.Key takeaway: Self-healing exists for the disruptions nobody asked for. PodDisruptionBudgets exist for the disruptions someone explicitly requested — a completely different problem requiring a completely different safeguard.What Actually Happens During kubectl drainUnderstanding the failure mode requires understanding what a Node drain actually does. When you run kubectl drain , Kubernetes evicts every Pod running on that Node — cordoning it first so no new Pods get scheduled there, then requesting each existing Pod be terminated so the Node can be safely taken offline.If a Deployment has three replicas, and Kubernetes’s scheduler happened to place all three on the same Node — which is entirely possible without additional configuration steering it otherwise — draining that one Node evicts all three simultaneously. The Deployment controller will, eventually, notice the gap and start new replacement Pods elsewhere. But “eventually” might mean your service has zero available replicas for the window between eviction and replacement being ready — and if that service is handling live traffic, that gap is a real, user-facing outage, not a theoretical edge case.Before drain:Node A: [ Pod-1 ] [ Pod-2 ] [ Pod-3 ] Node B: (other workloads)kubectl drain Node A | vNode A: (evicting all 3 Pods at once) | vService has 0 available replicas until replacements schedule and become ReadyKey takeaway: A Node drain doesn’t check whether it’s about to take down every replica of a service at once — without something stopping it, it will happily do exactly that.How a PodDisruptionBudget Actually Prevents ThisA PodDisruptionBudget doesn’t stop a Node from being drained, and it’s important to be precise about that — it’s not a hard block on maintenance happening at all. What it does is tell Kubernetes: “no matter what voluntary disruption is being requested, never let the number of available Pods matching this selector drop below this threshold, at any point, during that process.”apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: my-first-app-pdbspec: minAvailable: 2 selector: matchLabels: app: my-first-appWith this PDB in place, if someone runs kubectl drain on a Node holding some of my-first-app's replicas, Kubernetes's eviction API will evict Pods one at a time, checking the PDB before each eviction, and will simply refuse to evict a Pod if doing so would drop available replicas below minAvailable: 2. The drain command doesn't fail outright — it waits, retries, and proceeds only as new replacement Pods become available elsewhere to safely make room for further evictions, maintaining that guaranteed floor of two available Pods throughout the entire process.A PDB doesn’t say “don’t touch these Pods.” It says “you can touch them, one at a time, but never enough at once to break this floor.”Key takeaway: A PodDisruptionBudget doesn’t prevent maintenance — it paces it, forcing voluntary disruptions to respect a minimum availability floor instead of happening all at once.minAvailable vs. maxUnavailableA PDB spec uses one of two fields — never both — depending on which framing is more natural for your situation.minAvailable sets a floor: at least this many (or this percentage) of Pods must remain available at all times during a voluntary disruption.spec: minAvailable: 2maxUnavailable sets a ceiling instead: at most this many (or this percentage) of Pods can be unavailable at once.spec: maxUnavailable: 1For a Deployment with 3 replicas, minAvailable: 2 and maxUnavailable: 1 produce the exact same practical outcome — only one Pod can be disrupted at a time. The choice between them is mostly about which framing reads more naturally for your situation, though percentages can make the difference more meaningful:spec: minAvailable: "80%"Using a percentage instead of a fixed number is genuinely useful if your Deployment’s replica count changes over time — through manual scaling or an autoscaler — since a fixed minAvailable: 2 on a Deployment that later scales to 20 replicas barely protects anything anymore, while 80% scales proportionally with it.Key takeaway: minAvailable and maxUnavailable are two ways of expressing the same underlying constraint — pick whichever reads more naturally, and lean toward percentages if your replica count isn't fixed.What a PDB Does Not Protect You FromThis distinction matters enough to state plainly, because assuming a PDB is a complete availability guarantee is a genuinely common misunderstanding. A PodDisruptionBudget only governs voluntary disruptions — Node drains, autoscaler-driven Node removal, and similar administrator-initiated or system-initiated actions that go through the eviction API.It does nothing for involuntary disruptions — an actual Node crash, a kubelet dying unexpectedly, a hardware failure. In those cases, Pods simply disappear without going through the polite eviction process a PDB governs, and you’re back to relying on the Deployment controller’s ordinary self-healing to notice and recover, the same mechanism covered earlier in this series. A PDB and self-healing aren’t competing tools — they’re covering two genuinely different failure categories, and a resilient setup needs both.Key takeaway: A PodDisruptionBudget is not a general uptime guarantee — it specifically governs voluntary, eviction-based disruptions, and does nothing to change how involuntary crashes are handled.A Common Mistake: Setting It Too StrictIt’s worth flagging a real trade-off here, because an overly cautious PDB can cause its own problems. If you set minAvailable equal to your total replica count — say, minAvailable: 3 on a Deployment with exactly 3 replicas — you've effectively told Kubernetes that zero voluntary disruption is ever acceptable. That doesn't make your app safer; it means a Node drain involving any of those Pods will simply hang indefinitely, unable to proceed, because there's never a moment where evicting even one Pod wouldn't violate the budget.This becomes a genuine operational headache during cluster upgrades specifically, where Nodes need to be drained one at a time as a normal part of the process. An administrator who set PDBs this strictly, without realizing it, can find an entire cluster upgrade stuck, waiting on a drain that will never be allowed to complete.Key takeaway: A PDB set too conservatively doesn’t just fail to help — it can actively block legitimate maintenance from ever completing, which is its own kind of operational incident.Trying It YourselfUsing the my-first-app Deployment from earlier in this series (assuming it's scaled to at least 3 replicas), apply a PDB and then simulate the exact scenario this article opened with:kubectl apply -f pdb.yamlkubectl get pdbThe kubectl get pdb output shows ALLOWED DISRUPTIONS — a live count of exactly how many Pods matching this PDB's selector could currently be safely evicted without violating the budget. Watching that number in real time while draining a Node is a genuinely useful way to see the mechanism actually working, rather than just trusting the YAML did something:kubectl drain --ignore-daemonsets --delete-emptydir-dataIf your replicas are spread across multiple Nodes and the PDB is satisfied throughout, the drain proceeds smoothly. If evicting a Pod on that Node would violate the budget, you’ll see the drain pause and retry, waiting for a replacement Pod to become available elsewhere before continuing — the PDB visibly doing its job in real time.Why This Deserves a Deliberate Decision, Not a DefaultNone of this happens automatically. Kubernetes doesn’t create a PodDisruptionBudget for you when you create a Deployment, and it won’t warn you that your three replicas might all be sitting on the same Node when someone runs a drain next month. That silence is exactly why this particular gap catches experienced administrators, not just beginners — it’s easy to build genuine confidence in Kubernetes’s self-healing, deploy something in production, and never actually test what happens when a Node hosting all its replicas gets deliberately drained for routine maintenance.For anything you’d genuinely mind seeing go briefly unavailable — and especially anything involved in a planned Kubernetes version upgrade, which necessarily drains Nodes one at a time as standard procedure — writing a PodDisruptionBudget isn’t an advanced, optional hardening step. It’s the specific, correctly-named tool for the specific, correctly-named problem this article opened with.Have you ever had a maintenance window or cluster upgrade take down more than expected because a PDB wasn’t in place — or set too strictly to actually help?PodDisruptionBudget: The Safety Net Nobody Sets Up Until It’s Too Late was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.