Skip to main content

PodDisruptionBudget

A PodDisruptionBudget (PDB) is a Kubernetes policy that limits how many pods of a replicated application can be down at once during voluntary disruptions such as node drains and cluster upgrades. It keeps minimum availability while planned maintenance proceeds.

Voluntary vs involuntary disruptions

PDBs apply only to evictions made through the Eviction API: kubectl drain, cluster upgrades, and autoscaler scale-down. They cannot protect against hardware failure, kernel OOM kills, or a zone outage.

How a drain respects a PDB

flowchart TD D["kubectl drain node"] --> C{"PDB allows
another eviction?"} C -->|"Yes"| E["Evict a pod"] C -->|"No"| W["Wait and retry"] E --> R["Pod rescheduled elsewhere"] R --> C classDef start fill:#475569,color:#ffffff classDef decide fill:#FFEDD5,color:#1E293B classDef ok fill:#D1FAE5,color:#1E293B classDef wait fill:#FEE2E2,color:#1E293B class D start class C decide class E,R ok class W wait

Defining a PDB

YAML
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: trading-api-pdb
namespace: production
spec:
minAvailable: 4 # or use maxUnavailable
selector:
matchLabels:
app: trading-api
Field Meaning
minAvailable At least this many pods must stay available
maxUnavailable At most this many may be down

Both accept integers or percentages. Percentages scale automatically with autoscaled replica counts, for example minAvailable: "80%".

Bash
kubectl get pdb -n production
# ALLOWED DISRUPTIONS = healthy pods - minAvailable
kubectl drain mumbai-worker-2 --ignore-daemonsets --delete-emptydir-data

Troubleshooting

Symptom Likely cause Fix
Drain hangs forever Allowed disruptions is 0 Fix unhealthy pods or loosen the PDB
PDB not protecting Selector does not match pod labels Verify with a label query
Upgrade stalls minAvailable equals replicas Leave room for one disruption
Remember

A PDB can only be as good as the replica count. With 1 replica and minAvailable: 1, no voluntary eviction is ever allowed.

Tip

Keep replicas at least one greater than minAvailable, so there is always a pod you may disrupt.

Common Mistake

Setting minAvailable equal to the replica count. Allowed disruptions stay at 0 and no node can ever be drained.

Frequently Asked Questions

What counts as a voluntary disruption?

Node drains, cluster upgrades, and autoscaler scale-downs that use the Eviction API. A node crash or OOM kill is involuntary and ignores PDBs.

How can a PDB block a node drain forever?

By requiring as many pods as exist, so zero evictions are ever allowed, or when pods are unhealthy and the budget cannot be met. The drain waits indefinitely.

minAvailable or maxUnavailable?

Use minAvailable for strict availability guarantees and maxUnavailable, often a percentage, for services whose replica count changes with autoscaling.

Found a mistake, an outdated step or a broken link?