Deployment strategies and zero downtime
Recreate, rolling update, blue-green and canary deployments in Kubernetes, and how readiness probes, maxUnavailable 0, graceful shutdown and PodDisruptionBudgets give zero-downtime releases.
Transcript
Every deploy replaces running pods. A deployment strategy decides how the old version hands over to the new one.
Recreate stops every old pod, then starts the new ones. It is simple, but for a moment nothing is running, so users see downtime.
RollingUpdate is the default. It swaps pods gradually: maxSurge allows extra new pods, and maxUnavailable limits how many old pods can be missing.
Blue-green runs a full new copy beside the old one, then switches the Service over. Rollback is instant, but it needs double the capacity.
Canary sends a small share of traffic to the new version first, and grows it while the error rate stays low. Argo Rollouts can automate this.
To get zero downtime, add a readiness probe, so the Service only sends traffic to pods that are ready.
Then set maxUnavailable to zero, so an old pod is removed only after its replacement is ready.
Shut down gracefully: when a pod is terminated, a short preStop delay lets endpoints update, then the app finishes in-flight requests on SIGTERM.
Run at least two replicas with a PodDisruptionBudget, so a node drain never removes them all.
And keep database changes backward compatible, because the old and new versions run side by side.
Surge. Probe. Drain.
More in this series
2:349Load balancers, sessions and Redis
How a load balancer spreads traffic, why in-memory sessions and sticky sessions break, how Redis as a shared session store fixes it, and how Services, Ingress and stateless pods fit together in Kubernetes.
2:1610How Kubernetes autoscaling works
The HPA formula and its metrics, requests and scale-down stabilisation, the Vertical Pod Autoscaler, the Cluster Autoscaler and Karpenter for nodes, and KEDA for event-driven scaling.