Conservative Maintenance with PDBs

Ensuring High Availability During Voluntary Disruptions with Pod Disruption Budgets

The Fundamental Rule of PDBs

A Pod Disruption Budget (PDB) is a Kubernetes object that limits the number of concurrently unavailable pods for an application, ensuring service availability during **voluntary disruptions** only.

🔧Voluntary Disruptions (PDB Protected)

Actions you initiate where Kubernetes respects PDBs.

  • Node draining for maintenance.
  • Cluster upgrades.
  • Scaling down a cluster.

Involuntary Disruptions (Not Protected)

Unexpected failures where PDBs cannot help.

  • Hardware failure.
  • Kernel panic on a node.
  • Cloud provider outage.

The Node Maintenance Game

Try to drain `node-01` for maintenance. The drain will only succeed if all applications are protected by a valid Pod Disruption Budget.

Node: node-01

App A (3 Replicas)🛡️ PDB OK
App B (2 Replicas)🛡️ NO PDB
App C (1 Replica)🛡️ PDB Risky

Ready for maintenance drill...

Anatomy of a PDB

Hover over the keys in the YAML below for an explanation.

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: my-app-pdb
spec:
  selector:
    matchLabels:
      app: my-app
  minAvailable: 2

Hover over a highlighted key on the left.

PDB Impact & Interactions

PDBs directly influence other cluster operations. Select a scenario below to see how.

Real-World Use Cases & Impact

PDBs are essential for maintaining availability in many common operational scenarios.

Rolling Cluster Upgrades

PDBs ensure that as each node is drained for an upgrade, your applications migrate gracefully without dipping below their minimum availability threshold.

Avoiding Downtime During Auto-Scaling

When a cluster autoscaler removes an underutilized node, it respects PDBs, preventing the termination of pods that would reduce an application's availability.

Database Pod Protection

For a stateful database cluster, a PDB with `minAvailable: 2` is critical to prevent the loss of quorum during maintenance.

Compliance: Controlled Maintenance

PDBs provide a programmatic way to enforce availability SLAs. They can block automated maintenance if conditions are not safe, ensuring compliance.

“Zero Downtime is a Policy”: PDB Game

You need to perform maintenance on `node-01`. Follow the steps to safely drain the node without violating the application's availability policy.

node-01

node-02

Click Step 1 to begin...

Advanced Policy & CLI Reference

Unhealthy Pod Eviction Policy

IfHealthyBudget (Default): Unhealthy pods can only be evicted if their application is not already disrupted.

AlwaysAllow: Unhealthy pods can always be evicted, even if it violates the PDB. Useful for clearing stuck applications.

# Create a PDB
$ oc create poddisruptionbudget my-pdb --selector=app=rails --min-available=1

# List all PDBs
$ oc get pdb -A