Terraform & IaC (50 Qs)•Part 3: Kubernetes Infrastructure as Code & GitOps (31 - 42)
Pod Disruption Budgets (PDB) and Zero-Downtime Kubernetes Node Upgrades.
senior LevelMost AskedCode ExampleKubernetesApache Kafka
In Simple Words:
When upgrading Kubernetes worker nodes (kubectl drain), nodes are cordoned and pods evicted.
A Pod Disruption Budget (PDB) specifies the minimum number or percentage of replicas that must remain running simultaneously during voluntary disruptions:
yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: web-api
The drain operation pauses until new pods on other nodes become healthy, ensuring zero downtime.