Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Kubernetes Pod Disruption Budgets
& Safe Node Drains.

A misconfigured PodDisruptionBudget (such as minAvailable: 100% or minAvailable == replicas) sets disruptionsAllowed=0, causing kubectl drain and Karpenter/GKE/EKS node upgrades to hang indefinitely with HTTP 429 eviction blocks.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

If latency budgets leave no room for synchronous retries, never set minAvailable equal to replicas on single- or fixed-replica workloads; use maxUnavailable: 1 (or >=25%) with replicas >= 2, and monitor kube_poddisruptionbudget_status_pod_disruptions_allowed == 0.

TL;DR30-second simplified summary
▾

Core Mechanics: During a Kubernetes 1.28 -> 1.29 EKS upgrade across 180 nodes and 3 AZs, node drains stall for 6 hours with HTTP 429 Cannot evict pod as it would violate the pod's disruption budget.

Visual & Structural Flow: Depicts Blocked Drain (0 Allowed Disruptions) vs. Safe Rolling Eviction (kubectl drain / EKS -> K8s Eviction API -> PDB Controller -> App Pods); Maintaining Quorum & N-1 Capacity During Node Drains (Eviction API -> AZ-A / AZ-B Pods -> AZ-C Draining -> Prometheus / OPA).

Trade-Offs & Production: Deleting all PDBs unblocks node drains but allows the upgrade controller to evict every replica of a service simultaneously, causing an outage. Design PDBs so voluntary drains always succeed safely while protecting quorum: Never Set minAvailable == replicas: Run critical services with replicas >= 2 across AZs.

Failure Modes & Application: Disruption budgeting is vital across any orchestrated infrastructure: Zero-Downtime Cluster Upgrades: Enables automated EKS/GKE/Karpenter node rotation without manual intervention.

Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why Kubernetes PDBs & Safe Node Drains Matter.

Why this matters: The mechanism: understand how Why Kubernetes PDBs & Safe Node Drains Matter works from first principles.

During a Kubernetes 1.28 -> 1.29 EKS upgrade across 180 nodes and 3 AZs, node drains stall for 6 hours with HTTP 429 Cannot evict pod as it would violate the pod's disruption budget. Three broken PDBs block eviction: redis-cache (replicas: 1, minAvailable: 1), a StatefulSet with minAvailable: 100%, and a Deployment with maxUnavailable: 0.

Constraints:

  • Multi-AZ stateless services must keep at least N-1 replicas during voluntary drains.
  • Zero unapproved --force --grace-period=0 deletes on stateful production pods.
02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

Real-World Impact of Misconfigured PDBs.

Why this matters: The problem: see what breaks without Real-World Impact of Misconfigured PDBs under real concurrency or scale.

A PDB with allowedDisruptions == 0 turns routine maintenance into an operational deadlock:

  1. Blocked Security Upgrades: EKS/Karpenter cannot cordon and drain nodes, leaving CVEs unpatched for hours.
  2. Autoscaler Deadlock: Cluster Autoscaler / Karpenter cannot consolidate underutilized nodes.
  3. Panic Force-Deletes: Frustrated operators run --force --grace-period=0, bypassing preStop hooks and corrupting stateful storage.
Kubernetes Eviction API & PDB Check

Blocked Drain (0 Allowed Disruptions) vs. Safe Rolling Eviction

kubectl drain / EKSK8s Eviction APIPDB ControllerApp Pods1. POST /eviction (replicas=1,minAvail=1)2. disruptionsAllowed == 0 -> HTTP429!3. Fixed: replicas>=2 +maxUnavailable: 14. disruptionsAllowed=1 -> SIGTERM+ preStop5. New pod Ready -> next nodedrains

Ensuring disruptionsAllowed >= 1 lets the Eviction API gracefully drain nodes while preserving N-1 availability.

Engineering Decision Framework
Problem
How to implement Kubernetes Pod Disruption Budgets & Safe Node Drains without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
If latency budgets leave no room for synchronous retries, never set minAvailable equal to replicas on single- or fixed-replica workloads; use maxUnavailable: 1 (or >=25%) with replicas >= 2, and monitor kube_poddisruptionbudget_status_pod_disruptions_allowed == 0.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Kubernetes Pod Disruption Budgets & Safe Node Drains experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Naive Solution (and Why It Breaks).

Why this matters: The problem: see what breaks without Naive Solution under real concurrency or scale.

Think of Naive Solution (and Why It Breaks) as the intuition layer for Kubernetes Pod Disruption Budgets & Safe Node Drains: The problem: see what breaks without Naive Solution under real concurrency or scale.

Deleting all PDBs unblocks node drains but allows the upgrade controller to evict every replica of a service simultaneously, causing an outage. Conversely, setting minAvailable: 100% or maxUnavailable: 0 permanently blocks voluntary evictions whenever all pods are healthy—and even minAvailable: 2 on a 3-replica service blocks drains if 1 pod is temporarily CrashLoopBackOff.

Component Topology

Naive Solution (and Why It Breaks)

Ingress / LBingressK8s ControlcomputeWorker NodestorageApp Podscontrolactive trafficreconcileprobe / SIGTERM
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise Solution: `maxUnavailable` Budgets, `replicas >= 2` & Alerting.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Design PDBs so voluntary drains always succeed safely while protecting quorum:

  • Never Set minAvailable == replicas: Run critical services with replicas >= 2 across AZs (topologySpreadConstraints) and use maxUnavailable: 1 (or 25%) so HPA scaling never breaks the budget.
  • StatefulSets & Quorum: For 3-node Raft/etcd/Kafka clusters, set maxUnavailable: 1 so quorum (2/3) always holds.
  • Admissions & Prometheus Alerting: Reject minAvailable == 100% or maxUnavailable == 0 via Kyverno/OPA policies, and alert when kube_poddisruptionbudget_status_pod_disruptions_allowed == 0 for > 15m (using unhealthyPodEvictionPolicy: IfHealthyBudget in K8s 1.27+).
Multi-AZ PDB Quorum Safety

Maintaining Quorum & N-1 Capacity During Node Drains

Eviction APIChecks PDB before SIGTERMAZ-A / AZ-B Pods2+ healthy replicasAZ-C DrainingmaxUnavailable: 1Graceful drain

1.Use maxUnavailable: Scales cleanly with HPA unlike fixed minAvailable counts.

2.Minimum 2 Replicas: Single-replica pods cannot tolerate any disruption with a PDB.

3.K8s 1.27+ Policy: unhealthyPodEvictionPolicy: IfHealthyBudget unblocks stuck CrashLoop pods.

4.OPA / Kyverno Gate: Block maxUnavailable: 0 in CI/CD before it reaches EKS.

Topology spread + maxUnavailable: 1 + OPA admission checks guarantee zero-downtime EKS upgrades across 180 nodes.

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: billing-worker-pdb
spec:
  maxUnavailable: 1
  unhealthyPodEvictionPolicy: AlwaysAllow
  selector:
    matchLabels:
      app: billing-worker
---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: block-deadlocking-pdb
spec:
  validationFailureAction: Enforce
  rules:
    - name: disallow-zero-disruptions
      match:
        any:
          - resources:
              kinds: ["PodDisruptionBudget"]
      validate:
        message: "PDB must not set maxUnavailable=0 or minAvailable=100%."
        deny:
          conditions:
            any:
              - key: "{{ request.object.spec.maxUnavailable || '' }}"
                operator: Equals
                value: 0
              - key: "{{ request.object.spec.minAvailable || '' }}"
                operator: Equals
                value: "100%"

# 3-node quorum StatefulSet (e.g., Zookeeper/etcd): allows 1 node down at a time
spec:
  minAvailable: 2
  selector:
    matchLabels:
      app: zookeeper
05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where PDBs & Safe Drains Apply in System Design.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Disruption budgeting is vital across any orchestrated infrastructure:

  • Zero-Downtime Cluster Upgrades: Enables automated EKS/GKE/Karpenter node rotation without manual intervention.
  • Stateful Databases & Brokers: Protects Raft/Kafka quorum during kernel patching.
  • Cost Optimization: Lets Karpenter consolidate underutilized spot/on-demand nodes without violating SLAs.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why is `maxUnavailable: 1` generally safer than a fixed `minAvailable` count for Deployment PDBs?

Recommended Learning Flow