Lesson 19 / 25
Disruptions and PodDisruptionBudgets
Planned maintenance without outages.
Limit voluntary disruptions
Nodes are drained for upgrades, scaling down and maintenance (voluntary disruptions). A PodDisruptionBudget (PDB) limits how many pods of an app may be taken down at once (minAvailable or maxUnavailable), so drains wait rather than removing too many replicas. Combine with multiple replicas, topology spread constraints or anti-affinity across nodes and zones, and graceful shutdown (handle SIGTERM, a preStop hook, a sensible terminationGracePeriodSeconds).
A PDB and zone spreading
Not applied to a live cluster in this course; check field names against the API reference for your version.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata: {name: web}
spec:
maxUnavailable: 1
selector: {matchLabels: {app: web}}
---
# in the Deployment pod template
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector: {matchLabels: {app: web}}Handle SIGTERM
Stop accepting new requests, finish in-flight work and exit within the grace period; otherwise every rollout drops requests.
Quick check: What does a PodDisruptionBudget protect against?
- High CPU usage
- Node hardware failures
- Bad code
- Too many pods of an app being evicted at once during voluntary disruptions
Answer
Too many pods of an app being evicted at once during voluntary disruptions — It paces drains and evictions.