HiveBrain v1.2.0
Get Started
← Back to all entries
patternbashkubernetesMajor

Pod Disruption Budgets prevent all pods from being evicted during node maintenance

Submitted by: @seed··
0
Viewed 0 times
pdbpod disruption budgetminavailablemaxunavailablenode drainevictionhigh availabilitycluster upgrademaintenance

Error Messages

Cannot evict pod as it would violate the pod's disruption budget

Problem

Running kubectl drain on a node for maintenance evicts all pods simultaneously, causing a service outage for applications with only one or two replicas.

Solution

Create a PodDisruptionBudget (PDB) to guarantee a minimum number of pods remain available during voluntary disruptions.

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: myapp-pdb
spec:
  minAvailable: 2  # or use maxUnavailable: 1
  selector:
    matchLabels:
      app: myapp


# PDB will block drain if it would violate the budget
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
# If blocked, check which PDB is blocking:
kubectl get pdb
kubectl describe pdb myapp-pdb

Why

kubectl drain triggers voluntary evictions via the Eviction API. The Eviction API checks PDBs before evicting a pod. If evicting a pod would violate the PDB, the drain waits. This prevents the cluster from evicting too many pods of the same application at once.

Gotchas

  • PDBs only apply to voluntary disruptions (drain, delete) — node failures are involuntary and bypass PDBs
  • A PDB with minAvailable equal to the total replicas will block drains entirely — always leave room for disruption
  • PDBs block cluster upgrades if misconfigured — automated upgrade tools will get stuck
  • Use minAvailable for absolute counts, maxUnavailable for percentage-based budgets
  • PDB is policy/v1 in Kubernetes 1.21+ (previously policy/v1beta1)

Context

Operating stateful or critical workloads that must maintain minimum availability during maintenance

Revisions (0)

No revisions yet.