How do you achieve zero-downtime deployments in Kubernetes?

Neil Millard

This is done with rolling updates. New pods are provisioned and the old pods removed from the load balancer.

AWS ECS follows the same pattern. New tasks are provisioned whilst the old tasks are removed from the load balancer.

Keeping the old pods and tasks around long enough for the rolling update to complete, enables their quick reinstatement should a rollback need to happen.

Health-checks on container images and marking them as essential will help the deployment system know if the deployment is working.

The two settings that matter most are the readiness probe (so a new pod isn't sent traffic until it's actually ready) and a pre-stop hook with a grace period (so an old pod finishes in-flight requests before it's killed) — skipping either is the most common cause of dropped requests during an otherwise "zero-downtime" rollout.

Need help with your DevOps setup?

Get personalised advice from Neil Millard — DevOps consultant based in Weston-super-Mare.