Sub topic 16
Common budget mistakes that block maintenance
This chapter assumes you can write a PodDisruptionBudget (PDB), read kubectl get pdb, and know that kubectl drain evicts pods through the Eviction API. Here you will learn the configurations that make a drain hang or fail, and how to fix each one.
Mistake 1: a budget that allows zero disruptions
A budget with minAvailable equal to the replica count, or maxUnavailable: 0, allows no voluntary evictions at all. Every drain that touches one of its pods waits forever.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-pdb
spec:
minAvailable: 6
selector:
matchLabels:
app: webWith 6 replicas this budget gives disruptionsAllowed: 0. The fix is to leave headroom: maxUnavailable: 1 or minAvailable: 5.
Mistake 2: percentages that round the wrong way
Percentages are converted to pod counts. For minAvailable, the value is rounded up. For maxUnavailable, it is also rounded up, so maxUnavailable: 10% on 5 replicas allows 1 pod. A minAvailable: 100% budget blocks everything, just like Mistake 1. Prefer integers for small workloads, because the arithmetic is easier to predict.
Mistake 3: a single replica with a strict budget
A Deployment with replicas: 1 and minAvailable: 1 can never lose its pod voluntarily. The drain blocks until someone deletes the budget or scales the Deployment up. Either run at least two replicas, or accept that this workload will have downtime during maintenance and skip the budget.
Mistake 4: a selector that matches the wrong pods
The budget counts pods that match its selector in the same namespace. Two failure modes follow:
- The selector matches nothing, so the budget protects nothing.
- The selector is broad and matches pods from several workloads, so they share one budget and block each other.
Check what a budget covers with kubectl get pods -l app=web, and compare the count to the budget's expectedPods.
Mistake 5: not enough healthy pods
A budget counts only healthy (Ready) pods as available. If two of six pods are crash-looping and minAvailable is 5, the budget allows no disruption, because only four pods are healthy. The drain stalls on a problem unrelated to the node being drained. Fix the unhealthy pods first. On clusters that support it, unhealthyPodEvictionPolicy: AlwaysAllow lets the drain evict pods that are not Ready.
Mistake 6: overlapping budgets
If more than one PDB selects the same pod, the Eviction API refuses the eviction and returns an error. Keep one budget per set of pods.
Spotting the problem
kubectl get pdb -A
kubectl describe pdb web-pdbA column ALLOWED DISRUPTIONS of 0 is the first sign. Drain output repeating Cannot evict pod as it would violate the pod's disruption budget confirms it.
Exercise
A Deployment has 4 replicas, all Ready, and a PDB with minAvailable: 4. You run kubectl drain on a node that hosts one of its pods. What happens, and what is the smallest change that lets the drain finish?
Show answer
The drain waits and retries, because disruptionsAllowed is 0 (4 healthy minus 4 required). The smallest fix is to set minAvailable: 3 or maxUnavailable: 1, which allows one pod to be evicted.