惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
美团技术团队
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
T
Tailwind CSS Blog
U
Unit 42
C
Check Point Blog
S
SegmentFault 最新的问题
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
罗磊的独立博客
小众软件
小众软件
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
PodDisruptionBudgets: Your Kubernetes Outage Insurance
Naman · 2026-06-26 · via DEV Community
Cover image for PodDisruptionBudgets: Your Kubernetes Outage Insurance

Naman

It's Tuesday morning. The platform team starts draining nodes for a Kubernetes upgrade. Sixty seconds later, Slack explodes — the payment service is fully down. All 3 replicas landed on the same two nodes, both drained simultaneously. There was nothing wrong with the app. The cluster did exactly what it was told.*

This is what PodDisruptionBudgets prevent.


The Problem

Kubernetes has two kinds of pod disruptions:

  • Involuntary: Node crashes, OOM kills, hardware failures. Unpredictable. You handle these with replicas and health checks.
  • Voluntary: Node drains, cluster upgrades, autoscaler scale-downs, spot instance reclaims. Planned and controlled.

For voluntary disruptions, Kubernetes asks the eviction API to remove pods. By default, the eviction API has zero awareness of your application's availability requirements. It will happily evict every replica of your service at once if they're all on the node being drained.

Replicas don't help if the system removes all of them simultaneously.


What Is a PodDisruptionBudget?

A PDB is a simple declaration: "During voluntary disruptions, always keep at least N pods (or at most M pods unavailable) for this application."

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: payment-service-pdb
  namespace: production
spec:
  minAvailable: 2          # OR use maxUnavailable: 1
  selector:
    matchLabels:
      app: payment-service

That's it. This tells the eviction API: "You may not evict a payment-service pod if doing so would drop the available count below 2."


How It Works

┌─────────────────────────────────────────────────────────────┐
│                    WITHOUT PDB                              │
│                                                             │
│  kubectl drain node-2                                       │
│       │                                                     │
│       ▼                                                     │
│  Evict pod-A ──── ✓ Gone                                    │
│  Evict pod-B ──── ✓ Gone                                    │
│  Evict pod-C ──── ✓ Gone                                    │
│                                                             │
│  Result: 0/3 replicas running. Service DOWN.                │
│  (New pods schedule eventually, but there's a gap)          │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────-┐
│                     WITH PDB (minAvailable: 2)               │
│                                                              │
│  kubectl drain node-2                                        │
│       │                                                      │
│       ▼                                                      │
│  Evict pod-A ──── ✓ Allowed (3→2, still ≥ 2)                 │
│  Evict pod-B ──── ✗ BLOCKED (would go 2→1, violates PDB)     │
│       │                                                      │
│       ▼ (waits...)                                           │
│  pod-A reschedules on node-3 ──── ✓ Running                  │
│       │                                                      │
│       ▼ (now 3 available again)                              │
│  Evict pod-B ──── ✓ Allowed (3→2, still ≥ 2)                 │
│                                                              │
│  Result: Always ≥ 2 replicas running. Service STAYS UP.      │
└─────────────────────────────────────────────────────────────-┘

The drain operation becomes serialized and respectful — it waits for replacements to come healthy before continuing.


minAvailable vs maxUnavailable

Two ways to express the same idea:

Field Meaning Example (5 replicas)
minAvailable: 3 At least 3 must be running at all times Can evict up to 2 at once
maxUnavailable: 2 At most 2 can be down at once Same effect

You can also use percentages:

spec:
  maxUnavailable: "25%"    # For a 4-replica app: max 1 pod down

Rule of thumb: Use maxUnavailable for large deployments (scales naturally with replica count). Use minAvailable when you have a hard quorum requirement (e.g., etcd needs 2/3 members alive).


When You Need One

  • Any production service with > 1 replica
  • Stateful workloads with quorum (etcd, ZooKeeper, Kafka)
  • During cluster upgrades (nodes drain one by one)
  • When using cluster autoscaler (it respects PDBs during scale-down)
  • Spot/preemptible instances (cloud provider can reclaim nodes)

** When to Be Careful**

  • Don't set minAvailable equal to your replica count. A PDB of minAvailable: 3 on a 3-replica deployment means nothing can ever be evicted. Node drains will hang forever.
  • Don't forget PDBs block node drains. If your PDB is too strict and pods can't reschedule (due to resource pressure, node affinity, etc.), your drain operation will be stuck indefinitely.
  • Single-replica deployments: A PDB with minAvailable: 1 on a 1-replica app means the pod can never be evicted. Either accept downtime or add replicas.

The Minimum Viable PDB for Every Service

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: <app>-pdb
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app: <app>

One line of config. Guarantees at least one pod stays alive during any voluntary disruption. The cost: drains take slightly longer because they wait for rescheduling. The benefit: you never get paged because a routine node drain cascaded into an outage.


PDBs don't prevent disruptions. They civilize them — turning a shotgun blast into a controlled, one-at-a-time handoff. The five minutes it takes to add one is significantly less than the five hours debugging why a cluster upgrade took down production at 2 AM.*