What is PDB (PodDisruptionBudget) in kubernet

What is PDB (PodDisruptionBudget)?

PDB = Pod Disruption Budget

➡️ It is a Kubernetes object that controls how many pods can be down at the same time during planned (voluntary) disruptions.

Don’t allow too many pods to go down together during maintenance or updates.

Why we need PDB?

In Kubernetes, pods can be stopped during:

  • Node maintenance (kubectl drain)
  • Cluster upgrades
  • Auto-scaling
  • Rolling updates

Without PDB → Kubernetes may delete many pods → Application downtime ❌

With PDB → Kubernetes ensures minimum pods stay running ✅

Key Concepts in PDB

There are 2 main fields:

🔹 1. minAvailable

  • Minimum pods that must be running.
  • Example:
minAvailable: 2
Note: Always keep at least 2 pods alive

2. maxUnavailable

  • Max pods that can go down
  • Example:
maxUnavailable: 1
Note: Only 1 pod can be down at a time

3. Basic Example (Real YAML)

Example: Web app with 3 replicas

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

Meaning:

  • You have 3 pods
  • Kubernetes ensures at least 2 always running
  • Only 1 pod can be stopped

How to Use PDB (Step-by-Step)

Step 1: Create your Deployment

kubectl apply -f deployment.yaml

Step 2: Create PDB

kubectl apply -f pdb.yaml
OR
kubectl create pdb my-pdb --selector=app=nginx --min-available=1

Step 3: Check PDB

kubectl get pdb
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS
web-app-pdb 2 N/A 1

Step 4: Describe PDB (details)

kubectl describe pdb web-app-pdb
This entry was posted in DevOps on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply