DevOps & Kubernetes (50 Qs)•Part 3: Production K8s Scaling, Reliability & SRE (26 - 35)
Pod Disruption Budgets (PDB): Protecting high availability during voluntary disruptions and node drains.
High Availability Under Maintenance
Cluster maintenance operations (node draining, Kubernetes version upgrades, spot instance terminations) are voluntary disruptions. Without a PodDisruptionBudget (PDB), an engineer or automated script running kubectl drain node-1 could terminate all replicas simultaneously, taking down production.
arduino
[ Cluster Admin / Script: kubectl drain node ]
|
v
+-------------------------------------------------------+
| API Server Eviction Subresource |
| |
| Evaluates PodDisruptionBudget (PDB): |
| "At least 80% of payment-api pods MUST stay alive" |
+-------------------------------------------------------+
/ \
[ Replicas Healthy: 5/5 ] [ Replicas Healthy: 4/5 ]
Eviction ALLOWED (4/5 = 80%) Eviction BLOCKED / QUEUED!
(Node drains safely) (Waits for new Pod to be ready)
Production PDB Blueprint
yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: payment-api-pdb
namespace: production
spec:
minAvailable: 80% # Or fixed number: minAvailable: 2
selector:
matchLabels:
app: payment-api
Key PDB Rules
minAvailablevsmaxUnavailable: Define either a percentage (80%) or an absolute integer (1).- If a drain request would violate the budget, the eviction request fails with HTTP 429 (Too Many Requests), and the drain controller retries until new replicas become ready on another node.