Sub topic 14
Reading PodDisruptionBudget status
This chapter assumes you can create a PodDisruptionBudget (PDB) and know that kubectl drain evicts pods through the Eviction API. Here you will learn to read the status a PDB reports, because that status decides whether an eviction succeeds.
Where the numbers come from
The disruption controller watches the pods that match the PDB's selector. It counts them and writes the result to the PDB's status. The Eviction API reads that status, not your spec, when it decides whether to allow an eviction.
The status fields
| Field | Meaning |
|---|---|
| `currentHealthy` | Matching pods that are currently Ready |
| `desiredHealthy` | Minimum number of Ready pods the budget requires |
| `expectedPods` | Number of pods the controller expects, taken from the owning workload's replica count |
| `disruptionsAllowed` | How many more pods may be evicted right now |
| `conditions` | Whether the budget could be computed (`SufficientPods`) |
The key relationship is:
disruptionsAllowed = currentHealthy - desiredHealthyIf the result is negative, the field shows 0.
Worked example
Take the web-pdb budget with maxUnavailable: 1, applied to a Deployment with 6 replicas. The controller derives desiredHealthy as expectedPods - maxUnavailable, which is 5.
Instead of a diagram, read this table of states:
| Ready pods | desiredHealthy | disruptionsAllowed | Effect on a drain |
|---|---|---|---|
| 6 | 5 | 1 | One pod can be evicted |
| 5 | 5 | 0 | Evictions are refused |
| 4 | 5 | 0 | Evictions are refused until pods recover |
When a pod is evicted, currentHealthy falls to 5 and disruptionsAllowed falls to 0. The next eviction waits until the replacement pod is Ready.
Inspecting a budget
kubectl get pdb web-pdb
kubectl get pdb web-pdb -o jsonpath='{.status.disruptionsAllowed}{"\n"}'
kubectl describe pdb web-pdbThe kubectl get output shows MAX UNAVAILABLE and ALLOWED DISRUPTIONS. Use -o yaml when you need currentHealthy, desiredHealthy and expectedPods.
Reading what you see
ALLOWED DISRUPTIONSis 0 while all pods are Ready. The budget leaves no slack. This happens withminAvailableequal to the replica count, or withmaxUnavailable: 0. Drains will block until you change the budget.currentHealthyis belowdesiredHealthy. The workload is already degraded. Fix the unhealthy pods first, because a drain cannot proceed.expectedPodslooks wrong. With percentages, the controller needs a controller owner (Deployment, StatefulSet and similar) to find the replica count. Bare pods give unexpected results.- The status is stale or empty. Check that the selector matches pods. A selector that matches nothing reports 0 for every count.
Exercise
A PDB shows currentHealthy: 4, desiredHealthy: 5, expectedPods: 6. What is disruptionsAllowed, and what happens if you run kubectl drain on a node holding one of these pods?
Show answer
disruptionsAllowed is 0, because 4 - 5 is negative and the field does not go below 0. The drain's eviction request is refused and kubectl drain retries until pods recover and currentHealthy reaches at least 6.