Services

Resources

Company

PDB (Pod Disruption Budget)

A Pod Disruption Budget (PDB) tells Kubernetes how many pods of an application must stay up during voluntary disruptions, such as draining a node for an upgrade or scale-down. You set either minAvailable or maxUnavailable for pods matched by a label selector.

How it works

Tools that remove pods politely, such as kubectl drain, the Cluster Autoscaler and Karpenter, use the Eviction API, and it refuses evictions that would break the budget. Involuntary disruptions, such as a node crash, ignore it.

For example, a Deployment has 3 replicas, and 2 sit on the node being drained. Without a PDB, both are evicted at once and 1 pod serves all traffic. With minAvailable: 2, the drain evicts one, waits until its replacement is Ready, then evicts the next. Set minAvailable: 3 on 3 replicas and the drain blocks forever.

Why it matters in production

PDBs only protect against voluntary disruptions. A spot instance is reclaimed about two minutes after its interruption notice whether or not the budget allows it, so run enough replicas across zones as well. Check for budgets that block every eviction before cluster upgrades, because they stall node rotation.

See also

On the One2N blog

References

  1. Kubernetes: Disruptions

  2. Kubernetes: Specifying a Disruption Budget

Comic about Pod Disruption Budget: checkout runs 3 replicas and Asha drains node-1; with no PDB pods a and b are evicted together and one pod takes all traffic, so checkout times out; with minAvailable: 2 the Eviction API lets a go, refuses b with HTTP 429 until a's replacement is Ready, with no errors; minAvailable: 3 on 3 replicas makes the drain hang, and a spot reclaim gives 2 minutes, PDB or not.