PodDisruptionBudget
Protect planned maintenance
A PodDisruptionBudget (PDB) limits certain voluntary disruptions through the Kubernetes Eviction API, such as a normal eviction-based node drain. If five matching replicas are healthy and minAvailable is four, at most one healthy replica can be voluntarily evicted at that instant under the simplified assumptions. Once four are healthy, another healthy eviction must wait until availability recovers or the constraint changes. The PDB does not create replacement Pods, prevent node failure, or ensure a service meets its availability objective.
Define the correct selector and budget
This policy/v1 object matches catalog Pods in scaling-study. For this independent scenario the Deployment is intentionally assumed to have five desired replicas. The HPA fixture from the first lesson has a minimum of two; do not combine it blindly with this fixed minimum of four, because maintenance could be blocked when the workload scales down. The policy uses minAvailable; alternatively use maxUnavailable, never both. Match labels intentionally: an empty selector in policy/v1 selects all Pods in the namespace. Prefer one budget per intended workload and review overlap. This static manifest is for reading, not application.
apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: catalog namespace: scaling-studyspec: minAvailable: 4 selector: matchLabels: app: catalogRead the arithmetic and the status
For a conventional single-controller workload, minAvailable of 4 and 5 currently healthy matching Pods gives max(0, 5 − 4) = 1 allowed healthy disruption in a simple snapshot. With maxUnavailable of 1 and 5 desired replicas, desired healthy is 4. Percentages round up: with 7 desired replicas and maxUnavailable 30%, ceil(2.1) = 3 may be unavailable, leaving 4 desired healthy. A percentage can allow more disruption than expected for tiny workloads. Percentage or maxUnavailable calculations depend on the managing controller and intended replica count. Inspect currentHealthy, desiredHealthy, expectedPods, disruptionsAllowed and observedGeneration; pending evictions and stale status matter. This arithmetic is not an eviction authorization simulation.
Know what the budget cannot stop
Direct Pod deletion and controller-driven rolling updates are not blocked by PDB in the same way as Eviction API requests. Unplanned loss, such as a failed node, can reduce the healthy count below the budget. Such losses consume availability but are not prevented by PDB. For rolling updates configure Deployment maxUnavailable and maxSurge separately. A PDB is also not a substitute for zone spread, redundancy, readiness checks or data protection. Scheduler preemption considers budgets on a best-effort basis, not as an absolute prohibition.
Investigate a blocked maintenance window
An unhealthy Pod can complicate drain. The default IfHealthyBudget policy permits eviction of a running unready Pod when the application meets the budget; AlwaysAllow permits eviction of running unhealthy Pods even when the budget is not met. Verify the supported API and application recovery needs before choosing; the field is stable from Kubernetes 1.31. Other lifecycle states have separate rules. If a drain is blocked, inspect readiness and disruption allowance before attempting any action. Never bypass eviction safeguards just to finish a tutorial. The following commands are static read-only examples for a verified disposable environment; no actual drain is part of this package.
kubectl --kubeconfig ./lab.kubeconfig --context scaling-lab -n scaling-study get pdb catalogkubectl --kubeconfig ./lab.kubeconfig --context scaling-lab -n scaling-study describe pdb catalogPractice with independent snapshots
Use pdb-cases.json to calculate desired healthy counts and the simplified allowance. Review disruption-cases.json to identify whether the Eviction API budget is relevant. For a five-replica workload requiring four healthy Pods, design a sequential maintenance plan that waits for replacement readiness and stops when the budget is exhausted. If the HPA minimum is below the fixed PDB minimum, reconsider the intended availability policy and scaling range together. Real eviction decisions require a live API, current status and authorized maintenance.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
PodDisruptionBudget — knowledge check
Apply autoscaling and disruption concepts to offline scenarios.
Five matching replicas are healthy and minAvailable is 4. What is the simplified healthy disruption allowance?
Which operation normally uses PDB enforcement?
Seven desired replicas, maxUnavailable 30%. How many may be unavailable by the percentage calculation?
What does an empty selector in policy/v1 PDB select?
What is a risk of fixed minAvailable 4 with HPA minReplicas 2?