Skip to main content

Configuring Kubernetes Pod Disruption Budgets

Configure Kubernetes Pod Disruption Budgets so node drains and cluster upgrades never take a service below its minimum number of running pods.

52 Terms

Overview and What You Will Learn

A Pod Disruption Budget (PDB) tells Kubernetes the minimum number of pods that must stay available, or the maximum that may be down, while it deliberately evicts pods for maintenance. It protects a service during node drains, cluster upgrades and autoscaler scale-downs, where without a PDB all of a service's pods can be evicted at nearly the same time. In this lab you will use a throwaway multi-node cluster to see a PDB block a drain, fix the budget, and let the drain complete.

  • Choosing between minAvailable and maxUnavailable
  • Seeing exactly what a PDB does and does not protect
  • Reading ALLOWED DISRUPTIONS and the PDB status fields
  • Diagnosing a node drain that hangs
  • Protecting quorum-based StatefulSets
  • Combining a PDB with replicas, readiness probes and spread constraints

Why This Matters in Production

A PDB decides whether a routine upgrade is invisible or an outage. Imagine a payments API with three pods during a cluster upgrade that drains nodes one after another. A drain evicts pods immediately and does not wait for replacements to become Ready, so a quick sequence of drains can leave one pod, or none, serving production traffic. Cloud-managed upgrades on EKS, GKE and AKS respect PDBs, so a correct budget is often the only thing between an upgrade and a user-facing incident.

Core Principles

A PDB applies only to voluntary evictions made through the Eviction API, such as kubectl drain, node upgrades, and cluster autoscaler or Karpenter scale-downs. When an eviction would take the matching pods below the budget, the API refuses it, and the drain retries until a replacement pod is Ready elsewhere and the budget allows the eviction.

sequenceDiagram participant D as kubectl drain participant E as Eviction API participant P as PDB D->>E: Evict pod E->>P: Disruptions allowed? P-->>E: Yes or no E-->>D: Evicted, or retry later

Be precise about what a PDB does not cover:

Event Does a PDB apply?
kubectl drain, node upgrades, autoscaler scale-down Yes, they use the Eviction API
Deployment rolling updates No, controlled by maxUnavailable and maxSurge in the strategy
kubectl delete pod No, direct deletion bypasses the budget
Node crash, kernel panic, OOM kill No, these are involuntary

You set exactly one of two fields. minAvailable is the number or percentage of pods that must stay available, and maxUnavailable is the number or percentage that may be down. Percentages are rounded up, so maxUnavailable: "10%" with 5 pods allows 1 disruption, and minAvailable: "60%" with 3 pods requires 2.

Setting Best for Watch out
minAvailable: N A known floor, such as a quorum of 2 If replicas fall to N or below, drains block until you fix it
maxUnavailable: N Services that scale up and down Less obvious to read during an incident
A percentage Autoscaled workloads Round-up behaviour can surprise you on small replica counts
Security

Treat an unsatisfiable budget as an operational hazard. A PDB with minAvailable equal to the replica count, or a single replica with minAvailable: 1, makes drains wait forever, so upgrades stall until someone removes it.

Detailed Step-by-Step Practical Lab

Step 1 - Create a Throwaway Multi-Node Cluster

Drains need more than one node, so use kind with one control plane and three workers:

YAML
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
Bash
kind create cluster --name pdb-lab --config kind-pdb-lab.yaml
kubectl get nodes
Step 2 - Deploy a Service with Three Replicas

The readiness probe matters because a PDB counts only Ready pods. The spread constraint puts one pod on each node, so a single node drain affects one pod:

YAML
# payments-api.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: payments-api
spec:
replicas: 3
selector:
matchLabels:
app: payments-api
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: payments-api
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: payments-api
containers:
- name: api
image: nginx:1.27
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
Bash
kubectl apply -f payments-api.yaml
kubectl rollout status deployment/payments-api
kubectl get pods -l app=payments-api -o wide
Step 3 - Apply an Unsatisfiable Budget

Set minAvailable equal to the replica count, which is the classic mistake:

YAML
# pdb-bad.yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: payments-api-pdb
spec:
minAvailable: 3
selector:
matchLabels:
app: payments-api
Bash
kubectl apply -f pdb-bad.yaml
kubectl get pdb
# NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS
# payments-api-pdb 3 N/A 0

ALLOWED DISRUPTIONS of 0 means no pod can be evicted right now.

Step 4 - Watch a Drain Get Blocked

Drain the node that runs one of the pods. Use a timeout so the command ends by itself:

Bash
NODE=$(kubectl get pod -l app=payments-api -o jsonpath='{.items[0].spec.nodeName}')
kubectl drain $NODE --ignore-daemonsets --delete-emptydir-data --timeout=30s
# evicting pod default/payments-api-...
# error when evicting pods/"payments-api-..." (will retry after 5s):
# Cannot evict pod as it would violate the pod's disruption budget.

The drain keeps retrying until the timeout. Confirm why with the budget's live status:

Bash
kubectl get pdb payments-api-pdb -o yaml
# status: currentHealthy: 3, desiredHealthy: 3, disruptionsAllowed: 0, expectedPods: 3
kubectl get pods -l app=payments-api
Step 5 - Fix the Budget and Retry

Allow one pod to be unavailable at a time, then drain again:

YAML
# pdb-good.yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: payments-api-pdb
spec:
maxUnavailable: 1
unhealthyPodEvictionPolicy: AlwaysAllow
selector:
matchLabels:
app: payments-api
Bash
kubectl apply -f pdb-good.yaml
kubectl get pdb
# ALLOWED DISRUPTIONS should now be 1
kubectl drain $NODE --ignore-daemonsets --delete-emptydir-data
kubectl get pods -l app=payments-api -o wide
# The evicted pod was replaced on another node, and the service never dropped below 2 Ready pods

The unhealthyPodEvictionPolicy: AlwaysAllow setting lets Kubernetes evict pods that are already failing, so a crash-looping pod cannot block a drain forever.

Step 6 - Restore the Node
Bash
kubectl uncordon $NODE
Step 7 - Protect a Quorum-Based StatefulSet

Databases and coordination services such as ZooKeeper have no load balancer to absorb a loss, and they need a quorum. A three-node ZooKeeper cluster needs two nodes to elect a leader, so allow only one to be down:

YAML
# zookeeper-pdb.yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: zookeeper-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: zookeeper

For Kafka, derive the budget from min.insync.replicas and the replication factor, so a drain cannot stop producers from writing.

Step 8 - Use an Upgrade Checklist

Before a cluster upgrade, find every budget that currently blocks disruptions:

Bash
# 1. List all PDBs with their allowed disruptions
kubectl get pdb -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,ALLOWED:.status.disruptionsAllowed
# 2. Show only blocking budgets
kubectl get pdb -A --no-headers -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,ALLOWED:.status.disruptionsAllowed | awk '$3 == 0'
# 3. For each one, compare Ready pods with the budget
kubectl get pods -n NAMESPACE -l LABEL-FROM-PDB-SELECTOR
# 4. If pods are missing, scale up first, then drain
kubectl scale deployment NAME --replicas=4 -n NAMESPACE
Step 9 - Clean Up
Bash
kind delete cluster --name pdb-lab

Production Best Practices & Common Pitfalls

Common Mistake

Creating a PDB whose selector matches no pods. It exists but protects nothing. Check that kubectl get pdb shows the expected ALLOWED DISRUPTIONS, and that expectedPods in the status matches your replica count.

Tip

Make maxUnavailable: 1 the default for stateless services with more than one replica. It scales with the Deployment, it keeps drains moving, and it is the safest budget that still lets maintenance proceed.

Remember

A PDB limits evictions, but it does not spread pods or guarantee capacity. Pair it with at least two replicas, a readiness probe, and topology spread or anti-affinity so one node never holds every replica.

  • Never set a budget that cannot be met. minAvailable equal to replicas, maxUnavailable: 0, or one replica with minAvailable: 1 will stall upgrades.
  • Match selectors exactly. The PDB selector must match the pod template labels of the workload it protects, not the Deployment's own labels.
  • Count only Ready pods. Unready pods reduce the healthy count, so a service with failing probes can block drains even when pods are running.
  • Remember what bypasses PDBs. Direct pod deletion and Deployment rolling updates ignore the budget, so use rollout strategy settings for update safety.
  • Review budgets before upgrades. Managed upgrades wait on blocking budgets and can time out, so run the checklist ahead of time.
  • Keep one PDB per workload. Overlapping budgets on the same pods can make evictions fail with a configuration error.

Quick Reference & Troubleshooting Commands

Command Description
kubectl get pdb -n NS List budgets and allowed disruptions
kubectl describe pdb NAME -n NS Show a budget's selector and status
kubectl get pdb NAME -n NS -o yaml Read currentHealthy, desiredHealthy and disruptionsAllowed
kubectl drain NODE --ignore-daemonsets --delete-emptydir-data Evict pods from a node
kubectl uncordon NODE Make a drained node schedulable again
kubectl scale deployment NAME --replicas=N -n NS Add replicas so a budget can be met

Resources

Velero vs etcd Snapshot: Which Do You Need?

Velero vs etcd Snapshot: Which Do You Need?

Velero and etcd snapshots protect different layers of a Kubernetes cluster. See what each backs up, what each misses, and why most DR needs both.

11 min read•Aug 2026
Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient vs Linkerd in 2026: Which Mesh?

Istio Ambient cuts the sidecar tax at L4, but L7 adds waypoint hops, and Linkerd stable builds now come from Buoyant. Choose with tests.

11 min read•Aug 2026
Nginx Ingress vs Traefik vs Gateway API in 2026

Nginx Ingress vs Traefik vs Gateway API in 2026

Ingress-NGINX is retired. Compare Traefik and Gateway API controllers as replacements, plus a safe migration plan that avoids outages.

10 min read•Aug 2026
OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno: Policy Engine in 2026

OPA Gatekeeper vs Kyverno compared for 2026: Rego vs YAML, mutation, reporting, and operations, plus how to pick a Kubernetes policy engine.

10 min read•Aug 2026
Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize in 2026: Templating vs Patching

Helm vs Kustomize compared for 2026 - templating vs patching, Helm 4's new features, and why most production teams end up running both.

5 min read•Aug 2026
Prometheus vs Datadog vs New Relic: Real Costs

Prometheus vs Datadog vs New Relic: Real Costs

Prometheus, Datadog, and New Relic compared for 2026 - real pricing at scale, hidden cost drivers, and which fits a Kubernetes-heavy stack.

5 min read•Aug 2026
Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter for EKS in 2026

Cluster Autoscaler vs Karpenter on EKS: scale-up speed, bin-packing, Spot handling, Auto Mode limits and a safe migration path, with v1 NodePool YAML.

11 min read•Aug 2026
GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE vs EKS vs AKS in 2026: Which Fits Your Team?

GKE, EKS, and AKS compared for 2026 - control plane pricing, Autopilot vs Karpenter vs Node Auto Provisioning, and which platform actually fits your team.

5 min read•Aug 2026
K3s vs K8s vs MicroK8s: Which Distro in 2026?

K3s vs K8s vs MicroK8s: Which Distro in 2026?

Compare K3s, upstream Kubernetes and MicroK8s on footprint, datastores, HA and updates, and pick the right fit for edge, dev or production.

10 min read•Aug 2026
Canary Deployments with Argo Rollouts & Flagger

Canary Deployments with Argo Rollouts & Flagger

Ship to 5% of users first and auto-rollback on bad metrics: canary deployments on Kubernetes with Argo Rollouts, Flagger, and Gateway API.

11 min read•Jun 2026
OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry Explained: Metrics, Logs, Traces

OpenTelemetry in practice: instrument a Node.js service, run a production Collector, sample traces and link metrics, logs and traces in Grafana.

11 min read•Jun 2026
Kubernetes Cost Optimization Without SLO Risk

Kubernetes Cost Optimization Without SLO Risk

Kubernetes clusters average about 8% CPU use. Cut waste safely with request rightsizing, autoscaling, spot, and OpenCost, keeping SLOs.

11 min read•Jun 2026
ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD: GitOps for Kubernetes in 2026

ArgoCD vs FluxCD compared for 2026: UI, multi-tenancy, Helm, image automation and pruning risks, with a clear guide to picking your GitOps engine.

10 min read•Jun 2026

Explore More in Kubernetes Workload Management

All 6 Topics

Frequently Asked Questions

Is Configuring Kubernetes Pod Disruption Budgets free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Configuring Kubernetes Pod Disruption Budgets topic cover?

Configure Kubernetes Pod Disruption Budgets so node drains and cluster upgrades never take a service below its minimum number of running pods.

Found a mistake, an outdated step or a broken link?