Skip to content

Pod Disruption Budgets

Maintain availability during voluntary disruptions like node drains and cluster upgrades.

Time: ~10 minutes Difficulty: Intermediate

  • PodDisruptionBudgets (PDB): limit how many pods can be down simultaneously
  • minAvailable vs maxUnavailable and when to use each
  • How PDBs interact with kubectl drain and node maintenance
  • What counts as voluntary vs involuntary disruption

Navigate to the demo directory:

Terminal window
cd demos/pod-disruption-budgets
Terminal window
kubectl apply -f manifests/namespace.yaml
kubectl apply -f manifests/app.yaml
kubectl apply -f manifests/pdb-min-available.yaml

Check the PDB:

Terminal window
kubectl get pdb -n pdb-demo

You should see ALLOWED DISRUPTIONS: 2 (4 replicas - 2 minAvailable = 2 can be disrupted).

The kubectl drain command respects PDBs. On minikube (single node), we can simulate this with the eviction API:

Terminal window
# Try to evict pods one at a time
kubectl delete pod -l app=web-app -n pdb-demo --wait=false
kubectl get pods -n pdb-demo -w

Kubernetes will not evict pods below the minAvailable threshold during voluntary disruptions.

Terminal window
# Scale to 2 replicas (matches minAvailable exactly)
kubectl scale deploy web-app --replicas=2 -n pdb-demo
kubectl get pdb -n pdb-demo

Now ALLOWED DISRUPTIONS: 0. No voluntary evictions are possible.

Terminal window
# Scale back up
kubectl scale deploy web-app --replicas=4 -n pdb-demo
kubectl get pdb -n pdb-demo

ALLOWED DISRUPTIONS goes back to 2.

Delete the first PDB and apply the alternative:

Terminal window
kubectl delete pdb web-app-pdb -n pdb-demo
kubectl apply -f manifests/pdb-max-unavailable.yaml
kubectl get pdb -n pdb-demo

maxUnavailable: 1 means at most 1 pod can be down. With 4 replicas, ALLOWED DISRUPTIONS: 1.

manifests/
namespace.yaml # pdb-demo namespace
app.yaml # 4-replica Deployment
pdb-min-available.yaml # At least 2 pods must be running
pdb-max-unavailable.yaml # At most 1 pod can be unavailable

Voluntary vs involuntary disruptions:

Voluntary (PDB applies)Involuntary (PDB ignored)
kubectl drainNode crash
Cluster autoscaler scale-downOOM kill
Rolling updatesHardware failure
Manual eviction APIKernel panic

Choosing minAvailable vs maxUnavailable:

UseWhen
minAvailable: 2You need at least N pods for quorum or redundancy
maxUnavailable: 1You want to limit blast radius during maintenance
maxUnavailable: 25%Percentage-based for larger deployments
Terminal window
kubectl delete namespace pdb-demo

See docs/deep-dive.md for a detailed explanation of the eviction API, PDB interaction with rolling updates, unhealthy pod eviction policies, and PDB strategies for StatefulSets.

Move on to Prometheus & Grafana to learn cluster monitoring and observability.