Key Concepts
PDB
A policy that ensures a minimum number of pods remain available during voluntary disruptions.
Selector
Label selector that identifies which pods are protected by this budget.
Budget
Either minAvailable (minimum pods to keep) or maxUnavailable (maximum pods to disrupt).
Disruptions Allowed
Current number of pods that can be safely disrupted while maintaining the budget.
Required Permissions
| Action | Permission |
|---|---|
| View PDBs | iam:project:infrastructure:kubernetes:read |
| Create PDB | iam:project:infrastructure:kubernetes:write |
| Edit PDB | iam:project:infrastructure:kubernetes:write |
| Delete PDB | iam:project:infrastructure:kubernetes:delete |
PDB Status Values
| Status | Description |
|---|---|
| Allowed | Disruptions are allowed (disruptionsAllowed > 0) |
| Blocked | No disruptions allowed (disruptionsAllowed = 0) |
A “Blocked” status means the PDB is protecting pods at the budget limit. Operations like node drains will wait until more pods become available.
How to View PDBs
How to View PDB Details
Review Details
View PDB information including:
- Overview: Name, namespace, status, age
- Budget: minAvailable or maxUnavailable setting
- Pod Counts: currentHealthy, desiredHealthy, expectedPods, disruptionsAllowed
- Selector: Label selector matching protected pods
- Conditions: PDB controller conditions
- Labels & Annotations: Metadata attached to the PDB
How to Create a PDB
Write YAML
Enter the PDB manifest in YAML format. Key fields:
spec.selector- Label selector for target podsspec.minAvailable- Minimum pods that must be available (integer or percentage)spec.maxUnavailable- Maximum pods that can be unavailable (integer or percentage)
How to Edit a PDB
Modify Spec
Edit the PDB specification. Common changes:
- Adjust minAvailable or maxUnavailable values
- Update selector labels
- Modify metadata
How to Delete a PDB
Budget Types
PDBs support two mutually exclusive budget specifications:minAvailable
Specifies the minimum number of pods that must remain available:maxUnavailable
Specifies the maximum number of pods that can be unavailable:| Field | Type | Description |
|---|---|---|
| minAvailable | int or % | Minimum pods that must remain available |
| maxUnavailable | int or % | Maximum pods that can be unavailable at once |
Pod Counts Explained
| Field | Description |
|---|---|
| expectedPods | Total number of pods selected by the PDB |
| currentHealthy | Number of pods currently in healthy/ready state |
| desiredHealthy | Minimum healthy pods required by the budget |
| disruptionsAllowed | How many pods can currently be disrupted |
disruptionsAllowed = currentHealthy - desiredHealthy
If
disruptionsAllowed is 0, voluntary disruptions are blocked until more pods become healthy or the budget is modified.Troubleshooting
Node drain is stuck waiting
Node drain is stuck waiting
- Check if a PDB is blocking the drain (disruptionsAllowed = 0)
- Verify pods are healthy and ready
- Scale up the deployment temporarily to allow disruption
- Consider using
kubectl drain --disable-evictionfor emergencies (bypasses PDB)
PDB shows 0 expected pods
PDB shows 0 expected pods
- Verify the selector matches your pod labels
- Check pods exist in the same namespace as the PDB
- Use
kubectl get pods --selector=<labels>to verify selector
Cannot create PDB - validation error
Cannot create PDB - validation error
- Ensure you specify either minAvailable OR maxUnavailable, not both
- Percentage values must be strings with % suffix (e.g., “50%”)
- Integer values must be non-negative
- Selector must be valid label selector syntax
Disruptions allowed is negative
Disruptions allowed is negative
- This means fewer pods are healthy than required by the budget
- Check pod health and resolve any pod failures
- The budget is currently being violated - no disruptions will be allowed
PDB not protecting pods during deployment
PDB not protecting pods during deployment
- PDBs only protect against voluntary disruptions (node drain, delete)
- Rolling update strategy is separate from PDB
- Configure maxUnavailable in Deployment spec for rolling updates
- PDBs don’t prevent involuntary disruptions (node failure, OOM)
Cluster upgrade blocked by PDB
Cluster upgrade blocked by PDB
- PDBs can block node upgrades if pods can’t be evicted
- Ensure replicas > minAvailable to allow rolling evictions
- Consider temporarily relaxing the PDB during maintenance
- Scale up workloads before upgrades to allow eviction headroom
FAQ
What are voluntary vs involuntary disruptions?
What are voluntary vs involuntary disruptions?
Voluntary: Planned disruptions like node drain, cluster upgrade, pod deletion by admin. PDBs protect against these.Involuntary: Unplanned disruptions like hardware failure, kernel panic, OOM kills. PDBs cannot prevent these.
Should I use minAvailable or maxUnavailable?
Should I use minAvailable or maxUnavailable?
Can I have multiple PDBs for the same pods?
Can I have multiple PDBs for the same pods?
Yes, but it’s not recommended. Multiple PDBs selecting the same pods will all be enforced, potentially making eviction impossible. Use a single PDB per workload.
Do PDBs affect rolling deployments?
Do PDBs affect rolling deployments?
No. Rolling update behavior is controlled by the Deployment’s strategy, not PDBs. PDBs only affect voluntary pod evictions (like node drains), not the deployment controller replacing pods.
What happens if minAvailable equals replicas?
What happens if minAvailable equals replicas?
Can PDBs use percentage values?
Can PDBs use percentage values?
Yes. Both minAvailable and maxUnavailable accept percentages (e.g., “50%”). Percentages are calculated against the total number of pods matching the selector.
What is the difference between policy/v1beta1 and policy/v1?
What is the difference between policy/v1beta1 and policy/v1?
policy/v1 is the stable API (Kubernetes 1.21+) and should be used. policy/v1beta1 is deprecated. The main difference is that v1 has an empty selector behavior change.Do PDBs work with StatefulSets?
Do PDBs work with StatefulSets?
Yes. PDBs work with any pod controller (Deployments, StatefulSets, DaemonSets, ReplicaSets). The selector just needs to match the pod labels.