Kubernetes PodDisruptionBudget (PDB) Guide
Configure PodDisruptionBudgets to protect workloads during node drains, upgrades, and maintenance. minAvailable, maxUnavailable, and eviction policies.
π‘ Quick Answer: A PodDisruptionBudget (PDB) limits how many pods of a workload can be voluntarily disrupted at once during node drains, upgrades, or cluster autoscaler scale-downs. Set `minAvailable` (minimum pods that must stay running) or `maxUnavailable` (maximum pods that can be down simultaneously).
The Problem
During node maintenance, upgrades, or autoscaler operations, Kubernetes evicts pods. Without a PDB, all pods of a deployment could be evicted simultaneously, causing downtime. PDBs tell the eviction API βyou can take down at most N pods at a time.β
flowchart TB
subgraph WITHOUT["Without PDB"]
D1["Drain node-01"] --> E1["Evict pod-1 β
"]
D1 --> E2["Evict pod-2 β
"]
D1 --> E3["Evict pod-3 β
"]
E1 & E2 & E3 --> DOWN["π₯ 0/3 pods running<br/>DOWNTIME"]
end
subgraph WITH["With PDB (minAvailable: 2)"]
D2["Drain node-01"] --> F1["Evict pod-1 β
"]
D2 --> F2["Evict pod-2 β blocked"]
D2 --> F3["Evict pod-3 β blocked"]
F1 --> RESCHEDULE["pod-1 rescheduled"]
RESCHEDULE --> F4["Now evict pod-2 β
"]
endThe Solution
Using minAvailable
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-app-pdb
spec:
minAvailable: 2 # At least 2 pods must always be running
selector:
matchLabels:
app: web-app # Must match deployment labelsUsing maxUnavailable
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-app-pdb
spec:
maxUnavailable: 1 # At most 1 pod can be down at a time
selector:
matchLabels:
app: web-appPercentage Values
# At least 80% of pods must remain available
spec:
minAvailable: "80%"
selector:
matchLabels:
app: web-app
# At most 25% of pods can be unavailable
spec:
maxUnavailable: "25%"
selector:
matchLabels:
app: web-appWhich to Use?
| Setting | Best For | Example |
|---|---|---|
| `minAvailable: N` | Fixed minimum capacity | Database: always need 2 replicas |
| `maxUnavailable: 1` | Rolling eviction | Web apps: evict one at a time |
| `minAvailable: β80%β` | Scaling workloads | Percentage scales with replica count |
| `maxUnavailable: β25%β` | Large deployments | Allow quarter of fleet down |
Verify PDB Status
kubectl get pdb
# NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
# web-app-pdb 2 N/A 1 5m
kubectl describe pdb web-app-pdb
# Status:
# Current Healthy: 3
# Desired Healthy: 2
# Disruptions Allowed: 1
# Expected Pods: 3Common Issues
| Issue | Cause | Fix |
|---|---|---|
| Node drain stuck | PDB blocks all evictions | Reduce `minAvailable` or add replicas |
| PDB allows 0 disruptions | Not enough healthy pods | Scale up deployment first |
| Cluster autoscaler canβt scale down | PDB prevents eviction | Use `maxUnavailable: 1` instead of `minAvailable: N` where N = replicas |
| PDB doesnβt protect against crashes | PDB only covers voluntary disruptions | Use health probes + restart policies |
| Selector doesnβt match | Labels mismatch | Verify `kubectl get pods -l app=web-app` |
Best Practices
- Every production deployment should have a PDB β itβs free availability protection
- Use `maxUnavailable: 1` as default β works for most workloads
- Donβt set `minAvailable` equal to replicas β blocks all evictions including upgrades
- Use percentages for auto-scaling workloads β adapts to replica count
- Combine with pod anti-affinity β spread pods across nodes for true HA
- Test with `kubectl drain βdry-run` β verify PDB behavior before maintenance
Key Takeaways
- PDB limits voluntary pod disruptions (drains, upgrades, autoscaler) β not crashes
- `minAvailable`: minimum pods that must stay running
- `maxUnavailable`: maximum pods that can be down simultaneously
- Supports absolute numbers or percentages
- `ALLOWED DISRUPTIONS: 0` means no pods can be evicted β will block node drains
- Essential for zero-downtime maintenance and cluster upgrades

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
