How do you do zero-downtime deployments on Kubernetes?
IntermediateProductionRelease Engineering and Progressive Delivery
Answer
Combine: RollingUpdate with maxUnavailable: 0, accurate readiness probes, a preStop hook with a short sleep plus graceful shutdown handling SIGTERM (so in-flight requests finish before the pod is removed from endpoints), appropriate terminationGracePeriodSeconds, PodDisruptionBudgets, and multiple replicas across zones. Without the preStop delay, some requests hit a terminating pod because endpoint removal and SIGTERM race.
lifecycle:
preStop: { exec: { command: ["sleep", "10"] } }
terminationGracePeriodSeconds: 45
More on Release Engineering and Progressive Delivery
How do you implement a canary release with Argo Rollouts and automated analysis?AdvancedHow do you roll back safely when a deploy includes a database migration?AdvancedHow do you design an automated rollback trigger?AdvancedHow do you handle hotfixes in a trunk-based flow?IntermediateHow do you version and release libraries versus services?IntermediateWhat does a release train look like and when is it appropriate?Intermediate