What is a pod disruption budget?
sobes.tech AI
Answer from AI
Pod Disruption Budget (PDB) is a mechanism in Kubernetes that ensures a minimum number of application replicas are available during voluntary disruptions (such as node updates) or controlled shutdowns.
A PDB specifies either a minimum number or percentage of available pods (minAvailable), or a maximum number or percentage of unavailable pods (maxUnavailable). The Kubernetes API respects this budget and prevents operations that would violate the set limit. Such operations include:
- Deleting pods by controllers (Deployment, StatefulSet, etc.) during scale-down.
- Manually deleting pods with the
kubectl draincommand for node maintenance.
It only protects against voluntary disruptions, not forced ones (like node failures).
Example of a PDB for Deployment my-app:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: my-app-pdb
spec:
minAvailable: 80% # At least 80% of pods must remain available
selector:
matchLabels:
app: my-app # Selects pods with label app: my-app
In this example, Kubernetes will not allow voluntary disruptions to reduce the number of available pods with the label app: my-app below 80% of their total.