(01)Apply manifests
Linux
1kubectl apply -f deployment-with-labels.yml2kubectl apply -f pdb.yml3kubectl get pdb -n apps4kubectl describe pdb myapp-pdb -n appsKeep minimum pods available during node drains and cluster upgrades
pdb.yml
PDB for Deployment — at least 1 pod available during voluntary disruptions
1apiVersion: policy/v12kind: PodDisruptionBudget3metadata:4 name: myapp-pdb5 namespace: apps6spec:7 minAvailable: 18 selector:9 matchLabels:10 app: myapp11---12# Alternative: maxUnavailable for large fleets13# spec:14# maxUnavailable: 115# selector:16# matchLabels:17# app: myappdeployment-with-labels.yml
Deployment labels must match PDB selector
1apiVersion: apps/v12kind: Deployment3metadata:4 name: myapp5 namespace: apps6spec:7 replicas: 38 selector:9 matchLabels:10 app: myapp11 template:12 metadata:13 labels:14 app: myapp15 spec:16 containers:17 - name: app18 image: myapp:latest19 ports:20 - containerPort: 808021 readinessProbe:22 httpGet:23 path: /health24 port: 808025 initialDelaySeconds: 1026 livenessProbe:27 httpGet:28 path: /health29 port: 808030 initialDelaySeconds: 30Step 01
1kubectl apply -f deployment-with-labels.yml2kubectl apply -f pdb.yml3kubectl get pdb -n apps4kubectl describe pdb myapp-pdb -n apps1# voluntary disruption — should respect minAvailable2kubectl drain <node> --ignore-daemonsets --delete-emptydir-data3# undo: kubectl uncordon <node>