Skip to main content
K8sCalc

kubernetes

Kubernetes PodDisruptionBudget Generator

Generate a Kubernetes PodDisruptionBudget YAML to protect your workloads during node drains, rolling updates, and cluster upgrades.

Kubernetes PodDisruptionBudgets

PDBs prevent voluntary disruptions from causing downtime. They're essential for production workloads.

Without a PDB

kubectl drain node-1  →  all 3 pods evicted at once  →  downtime

With minAvailable: 1

kubectl drain node-1  →  evict pod-1  →  wait for new pod to be ready
                      →  evict pod-2  →  wait...  →  no downtime

Percentage-Based Policy

yaml
spec:
  maxUnavailable: 34%   # for a 3-pod deployment: floor(3 × 0.34) = 1 pod

Check PDB Status

bash
kubectl get pdb -n default
# Output:
# NAME         MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE
# my-app-pdb   1               N/A               2                     5d

ALLOWED DISRUPTIONS = current_replicas - minAvailable

If ALLOWED DISRUPTIONS = 0, no voluntary evictions are permitted — you have exactly minAvailable pods running.

PDB for StatefulSets

yaml
spec:
  minAvailable: 2   # for a 3-node cluster: never go below quorum
  selector:
    matchLabels:
      app: my-db

Frequently Asked Questions

What is a PodDisruptionBudget?

A PDB limits how many pods of a workload can be voluntarily disrupted at the same time. 'Voluntary' means: node drains (kubectl drain), rolling updates, cluster upgrades, node pool scaling. Involuntary disruptions (node crash, OOM kill) are NOT limited by PDBs. A PDB with minAvailable: 1 tells Kubernetes: 'never voluntarily take down all pods, always keep at least 1 running.'

minAvailable vs maxUnavailable — which should I use?

minAvailable is more intuitive: 'keep at least N pods running'. Use it when you know how many pods you need alive. maxUnavailable is the inverse: 'allow at most N pods down simultaneously'. It's more natural for percentage-based policies. Example: minAvailable: 1 is equivalent to maxUnavailable: replicas-1. For a 3-replica Deployment, minAvailable: 2 = maxUnavailable: 1.

Does a PDB block kubectl drain?

Yes — if draining a node would violate the PDB, kubectl drain will block and wait. The node drain succeeds only when pods can be safely evicted without breaking the budget. This is the whole point of PDBs. If drain gets stuck, check: kubectl get pdb -n <namespace> to see which PDB is blocking and how many pods are currently available.

Should I add a PDB to every Deployment?

Yes for any production workload with multiple replicas. Without a PDB, a rolling cluster upgrade or node drain can take down all replicas simultaneously if they happen to be on the same nodes. The generated PDB with minAvailable: 1 is the minimum useful config — for critical services, use minAvailable: 2 or a percentage like 50%.

Related Calculators

Related Guides