What is pod disruption budget and why does it matter?
Understand Kubernetes PodDisruptionBudgets: how minAvailable and maxUnavailable keep apps available during node drains, upgrades and autoscaling.
Expected Interview Answer
A PodDisruptionBudget (PDB) is a Kubernetes object that limits how many pods of an application can be voluntarily disrupted at once, ensuring a minimum number stay available during operations like node drains, upgrades and autoscaling.
A PDB targets a set of pods via a selector and specifies either minAvailable or maxUnavailable. It only governs voluntary disruptions — such as kubectl drain, cluster upgrades, or scale-down — which respect the budget through the Eviction API; it does not protect against involuntary disruptions like hardware failure. If evicting a pod would violate the budget, the eviction is blocked until another pod becomes ready, so maintenance proceeds without dropping below the required availability. It matters because it lets cluster operators perform routine maintenance safely without taking your service below a quorum or capacity floor.
- Guarantees minimum availability during maintenance
- Prevents node drains from taking down too many replicas
- Protects stateful quorums during upgrades
- Coordinates safely with the cluster autoscaler
- Decouples app availability needs from operator actions
AI Mentor Explanation
A PodDisruptionBudget is like a rule that a fielding side can never send more than a set number of players off the field for drinks at once — enough must stay to keep bowling and fielding. When the physio wants to rotate players (a voluntary change), they must wait until a replacement is ready, so the team never drops below a playable eleven during the over.
Step-by-Step Explanation
Step 1
Identify the workload
Choose the Deployment or StatefulSet whose availability must be protected during maintenance.
Step 2
Pick the budget type
Decide between minAvailable (absolute or percentage that must stay up) or maxUnavailable.
Step 3
Write a selector
Set spec.selector to match the pods' labels so the PDB governs the right set.
Step 4
Apply the PDB
kubectl apply the PodDisruptionBudget; it now guards voluntary evictions via the Eviction API.
Step 5
Verify during drain
Run kubectl drain on a node and confirm evictions block rather than breach the budget.
What Interviewer Expects
- PDB limits voluntary disruptions, not involuntary ones
- Understanding of minAvailable vs maxUnavailable
- How PDBs interact with kubectl drain and the Eviction API
- Relevance to node upgrades and cluster autoscaling
- Awareness that a misconfigured PDB can block maintenance entirely
Common Mistakes
- Believing a PDB protects against node hardware failure
- Setting minAvailable equal to replicas, which blocks all drains
- Confusing PDB with a Deployment's maxUnavailable rollout setting
- Using a selector that matches no pods so the PDB is inert
- Forgetting PDBs only take effect through eviction, not deletion
Best Answer (HR Friendly)
“A pod disruption budget is a rule that keeps a minimum number of an app's copies running while the cluster is being maintained. It matters because it lets operators upgrade or drain machines without accidentally taking the service offline.”
Code Example
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: web# maxUnavailable variant
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-pdb
spec:
maxUnavailable: 25%
selector:
matchLabels:
app: web
---
# check the budget status and test it
# kubectl get pdb web-pdb
# kubectl drain <node> --ignore-daemonsets --delete-emptydir-dataFollow-up Questions
- What is the difference between voluntary and involuntary disruptions?
- When would you use minAvailable versus maxUnavailable?
- How can a PDB accidentally block a node drain indefinitely?
- How do PDBs interact with the cluster autoscaler?
- Why must minAvailable never equal the replica count for single-tolerant apps?
MCQ Practice
1. Which type of disruption does a PodDisruptionBudget protect against?
A PDB only governs voluntary disruptions handled through the Eviction API; it cannot prevent involuntary events like hardware failure.
2. What happens if evicting a pod would violate its PDB?
The Eviction API rejects the eviction until enough pods are ready to keep the workload within its disruption budget.
3. Which setting risks blocking all node drains?
Setting minAvailable equal to the number of replicas leaves no room to evict any pod, so drains can never proceed.
Flash Cards
What is a PodDisruptionBudget? — An object limiting how many pods can be voluntarily disrupted at once, keeping a minimum available during maintenance.
minAvailable vs maxUnavailable? — minAvailable sets the floor that must stay up; maxUnavailable caps how many can be down. Use one or the other.
Does a PDB stop hardware failures? — No — it only governs voluntary disruptions like drains and upgrades via the Eviction API, not involuntary failures.
How can a PDB break maintenance? — If minAvailable equals replicas, no pod can be evicted, so kubectl drain blocks indefinitely.
Which API enforces a PDB? — The Eviction API — voluntary evictions are checked against the budget and rejected if they would violate it.
Continue Learning
Related Interview Questions
How do you drain a node safely, and what do you do when a PodDisruptionBudget blocks the eviction?
hard
What is a Kubernetes PodDisruptionBudget?
medium
Nodes stay half-empty and the Cluster Autoscaler never removes them — what blocks scale-down?
hard
How do liveness, readiness, and startup probes differ in Kubernetes?
medium