Skip to content

Pod Disruption Budgets — keeping voluntary evictions from breaking the SLO

How PodDisruptionBudgets actually work, when they block a drain, and the minAvailable vs maxUnavailable choice that decides whether your service survives a rolling node update.

A node update is a voluntary disruption. kubectl drain is a voluntary disruption. The Cluster Autoscaler scaling down a node is a voluntary disruption. Without a PodDisruptionBudget, any of these can evict every pod backing a service simultaneously and the request rate goes to zero for the duration of the reschedule. PodDisruptionBudgets (PDBs) are the mechanism that tells Kubernetes “for this workload, evict at most N at a time, and refuse the request if you cannot honor that.” This article is what a PDB actually does, what it does not do, and the two operational shapes we use.

How to verify

What the cluster currently has:

kubectl get pdb --all-namespaces
kubectl describe pdb -n team-api api-pdb
kubectl get pdb -n team-api api-pdb -o jsonpath='{.status.currentHealthy}/{.status.desiredHealthy} healthy, {.status.disruptionsAllowed} allowed{"\n"}'

The single most useful number is disruptionsAllowed. If it is zero, the next eviction request will be rejected with a 429 — the drain will stall there until either the budget recovers or the operator forces past it. A drain stuck at “evicting pod xxx” for ten minutes is almost always a PDB pinning the eviction.

What’s happening

A PDB is a budget on simultaneous voluntary disruptions for a set of pods. The selector matches pods; the budget sets either the minimum that must remain available (minAvailable) or the maximum that may be unavailable (maxUnavailable).

When something tries to evict a pod — kubectl drain, the Cluster Autoscaler, a node-update controller, a kubectl delete pod against a node being cordoned — the API server runs the eviction through the PDB admission check. If allowing the eviction would push the budget below its threshold, the API returns a 429 and the eviction caller has to retry or give up.

Critical distinction: PDBs only apply to voluntary disruptions. They do nothing for:

  • A node hardware failure.
  • A kernel panic that kills the kubelet.
  • A network partition.
  • kubectl delete pod without --force=false --grace-period=0 (which goes through the regular delete path, not eviction).

This is the trap most teams hit: they set minAvailable: 1 and assume that means “at least one replica is always running.” It does not. It means “no voluntary disruption may take the available count below 1.” A pod can crash, get OOMKilled, fail liveness — none of that touches the PDB. The PDB only protects you against operator-driven and controller-driven evictions.

minAvailable vs maxUnavailable:

  • minAvailable: 2 says “always keep at least 2 healthy.” Works for both percentages and absolute counts. Good for small replica counts where you know the minimum exactly.
  • maxUnavailable: 25% says “at most 25% may be down at once.” Better for HPAs where the replica count changes — a 25% bound scales with the workload.

The percent form has a rounding pitfall worth knowing. maxUnavailable: 33% on a 4-replica Deployment rounds down to 1 — only one pod can be evicted at a time. minAvailable: 50% on a 3-replica Deployment rounds up to 2 must-remain — so only 1 can be evicted. Always check the math against your actual replica counts.

The other operational shape is “this workload cannot tolerate a drain at all.” A minAvailable set to the full replica count means every drain attempt against a pod in this PDB will fail until the pod is moved by other means (kubectl delete pod with force, manual migration). This is a deliberate lock — useful for stateful workloads where eviction-during-drain is not safe.

The procedure

  1. Decide the budget for each workload class. The decision tree we use:

    • Stateless web tier with 3+ replicas behind a service: maxUnavailable: 25% and a topologySpreadConstraints to spread across zones.
    • Stateless web tier with 2 replicas: minAvailable: 1. One pod always up.
    • Singleton workload that you cannot run 2 of (a single-replica app that holds a coordination lock): no PDB. A PDB of minAvailable: 1 on a 1-replica workload would block every drain forever. Mark the namespace as “drain requires manual coordination.”
    • Stateful HA (etcd, MongoDB replica set, Patroni): maxUnavailable: 1. Only one member may rotate at a time.
    • Batch/job workload: no PDB. Jobs are idempotent and re-runnable; let them die.
  2. Write the PDB. For a Deployment named api with 4 replicas:

    apiVersion: policy/v1
    kind: PodDisruptionBudget
    metadata:
      name: api-pdb
      namespace: team-api
    spec:
      maxUnavailable: 1
      selector:
        matchLabels:
          app: api

    The selector must match the Pod template labels — not the Deployment labels. A common bug is matching app.kubernetes.io/name: api when the actual Pod template uses app: api. Test with:

    kubectl get pods -n team-api -l app=api
    kubectl get pdb api-pdb -n team-api -o jsonpath='{.status.expectedPods}{"\n"}'

    If expectedPods is zero, the selector matches nothing and the PDB is effectively a no-op.

  3. Simulate a drain in staging. Cordon one node and drain it; confirm the eviction respects the PDB:

    kubectl cordon node-3
    kubectl drain node-3 --ignore-daemonsets --delete-emptydir-data --timeout=10m

    In a second terminal, watch the PDB status update as evictions proceed:

    watch kubectl get pdb -n team-api

    The currentHealthy count should drop briefly as a pod evicts, then recover as the replacement schedules and passes readiness. If disruptionsAllowed stays at zero for minutes, your readiness probes are too slow or the replacement pod is not scheduling — investigate before relying on the PDB in production.

  4. Pin the PDB to the workload’s lifecycle. Ship the PDB in the same Helm chart / Kustomize overlay / manifest set as the Deployment it protects. A PDB that lives in a separate “platform” repo and gets out of sync with the workload it covers is worse than no PDB — it pretends to protect something that no longer matches.

Common pitfalls

  • A PDB blocking a drain looks identical from the outside to a “drain hung” bug. Always check kubectl get pdb -A first when troubleshooting a stuck drain. The error message in the drain output (Cannot evict pod as it would violate the pod's disruption budget) is your guide.
  • kubectl drain --disable-eviction bypasses the PDB. Useful for emergencies; do not use it in routine automation or you have effectively disabled every PDB on the cluster.
  • The Cluster Autoscaler honors PDBs by default but has a max-graceful-termination-sec (default 600s) past which it will force-delete a pod regardless. A PDB cannot pin a pod forever against the autoscaler.
  • A PDB with minAvailable: 100% and a 1-replica StatefulSet effectively blocks all node updates that touch that pod’s node. Some operators do this intentionally for “manual coordination required” workloads; if you did not intend it, you have a node that cannot be patched without manual intervention.
  • PDB selectors do not follow the Deployment → ReplicaSet → Pod ownership chain. The selector matches pods directly. During a rolling update, both old-RS and new-RS pods may match the same PDB, which is normally fine but matters if you label-version your pods.

Stack Harbor manages clusters where every Deployment has a matching PDB shipped in the same manifest set, drain runbooks check kubectl get pdb -A before touching a node, and the maintenance window is sized to the slowest-rolling PDB on the cluster. If your last node update took six hours because three drains stalled silently on misconfigured PDBs, the audit is the first deliverable of clustered environments management.