Pod Disruption Budget: What It Is & How It Works
- Availability %
- %
- Result
- Total pods
- 10
- You entered
- Min available
- 8
- You entered
A Pod Disruption Budget (PDB) is a Kubernetes policy that limits the number of pods in a ReplicaSet, Deployment, or StatefulSet that can be voluntarily evicted at the same time. You define a minimum number or percentage of pods that must remain available during voluntary disruptions, and Kubernetes blocks evictions that would drop availability below that threshold. This ensures that maintenance operations like node drains, cluster upgrades, or autoscaling don’t take down your entire application at once.
Formula
The PDB calculation is straightforward: Max Unavailable = Total Pods – Min Available. If you specify minAvailable instead of maxUnavailable, the controller computes the number of pods it can evict while keeping at least that many running. The formula is:
maxDisruptions = totalPods - minAvailable
Where:
- Total Pods – the current number of running pods for the workload (e.g., 10).
- Min Available – the number of pods that must remain running after an eviction (e.g., 8).
- Max Disruptions – the maximum number of pods that can be evicted at once (e.g., 2).
If you use maxUnavailable, the formula is reversed: maxDisruptions = maxUnavailable directly, and the controller ensures that the number of unavailable pods never exceeds that value.
Worked Example
Suppose you have a Deployment with 10 replicas, and you set minAvailable: 8. The PDB controller calculates:
- Total pods = 10
- Min available = 8
- Max disruptions = 10 – 8 = 2
So during a node drain, Kubernetes will only evict 2 pods at a time. After each eviction, it waits for the replacement pod to become ready before allowing another eviction. The availability percentage is 8/10 = 80%.
What Counts as a Voluntary Disruption?
Kubernetes distinguishes between voluntary and involuntary disruptions. A PDB only protects against voluntary actions – things an administrator or automation triggers on purpose. Common examples include:
- Draining a node for maintenance or repair.
- Cluster autoscaler removing nodes to save cost.
- Upgrading the Kubernetes version (which often requires node replacement).
- Manually deleting pods with
kubectl delete pod. - Using a tool like Descheduler to rebalance pods.
Involuntary disruptions – hardware failures, network partitions, kernel panics, or a node being force-deleted – are not covered by a PDB. If a node dies, the pods on it are gone regardless of the PDB.
How to Choose minAvailable vs maxUnavailable
You can specify either minAvailable or maxUnavailable, but not both. The right choice depends on your workload:
- minAvailable – use when you need a hard guarantee on the number of running pods. For example, a database with 3 replicas might set
minAvailable: 2to ensure quorum. - maxUnavailable – use when you care more about how many pods can be down at once. For a web service with 10 replicas,
maxUnavailable: 2means you can tolerate 20% downtime during maintenance.
Both accept either an integer or a percentage. Percentages are rounded up for minAvailable and rounded down for maxUnavailable. For example, with 10 pods, minAvailable: 30% means 3 pods must stay up, while maxUnavailable: 30% allows 3 pods to be down.
Common Mistakes and Misconceptions
One common mistake is setting a PDB on a workload with fewer replicas than the minimum. If you have 2 replicas and set minAvailable: 2, the PDB blocks all voluntary evictions – you cannot drain any node. That might be intentional, but it can stall cluster upgrades.
Another misconception is that a PDB guarantees zero downtime. It only limits the number of pods evicted at once. If your application requires all replicas to be ready to serve traffic (e.g., a stateful leader), even a single eviction can cause an outage. Also, PDBs do not prevent involuntary disruptions – a node failure can still take down all pods.
Finally, PDBs apply only to pods that are part of a workload with a controller (Deployment, StatefulSet, ReplicaSet). Standalone pods (not managed by a controller) are not protected. Also, the PDB must be in the same namespace as the pods it protects.
How PDBs Interact with Node Drains and Cluster Autoscaler
When you run kubectl drain, the node is cordoned first (no new pods are scheduled), then pods are evicted one by one. The drain command respects PDBs – it will not evict a pod if doing so would violate the PDB. The drain will hang until the PDB allows eviction, which can happen when a replacement pod becomes ready elsewhere.
Cluster Autoscaler also respects PDBs. Before removing a node, it checks whether the pods on that node can be rescheduled without violating any PDB. If not, the node is not removed. This can lead to nodes being stuck if the cluster is underutilized but the PDB is too strict.
In practice, this means a PDB can slow down maintenance. A node drain might take minutes or even hours if the cluster cannot quickly spin up replacement pods. Plan for this by having spare capacity or by temporarily relaxing the PDB during large maintenance windows.
Frequently Asked Questions
What happens if a PDB blocks a node drain?
The drain command will keep retrying until the PDB allows eviction. It will not forcibly delete pods. You can either wait for replacement pods to become ready, or temporarily edit the PDB to allow more disruptions. If you must proceed immediately, you can use --disable-eviction on the drain command, but that bypasses the PDB and can cause downtime.
Can a PDB protect against node failure?
No. PDBs only control voluntary evictions. If a node crashes or is terminated by the cloud provider, the pods on it are lost immediately. The PDB does not influence how quickly the ReplicaSet controller replaces them – that is handled by the replication controller.
Should I set a PDB on every workload?
Not necessarily. Stateless applications that can tolerate losing a few pods might not need a PDB, but it is a good practice for anything that requires a minimum number of replicas. For stateful workloads like databases or message queues, a PDB is often critical to maintain quorum. However, setting a PDB on a single-replica workload with minAvailable: 1 will block all voluntary evictions, which can be problematic.
What is the difference between a PDB and a horizontal pod autoscaler?
A Horizontal Pod Autoscaler (HPA) changes the number of replicas based on CPU or custom metrics. A PDB does not change replica counts – it only restricts how many can be unavailable during voluntary disruptions. They work together: HPA adds or removes pods, and PDB ensures that scaling down does not violate availability requirements.
How do I check if a PDB is blocking an eviction?
Use kubectl get pdb to see the current status. The ALLOWED DISRUPTIONS column shows how many pods can be evicted right now. If it shows 0, the PDB is blocking evictions. You can also describe a pod to see if it has a PDB attached and check the events for eviction failures.