Interview Prep/Real-World Interview/Deployments and releases

How would you design a zero-downtime deployment for a stateless API on Kubernetes?

BeginnerScenarioDeployments and releases
Answer

Situation read → Zero downtime needs four things together: a rolling strategy that never drops capacity, accurate readiness, graceful shutdown, and enough replicas.

What I'd do →

  1. Rolling update that adds before removing:
strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 25%
    maxUnavailable: 0
  1. A readiness probe that checks the app can actually serve (DB pool ready), separate from liveness.
  2. Graceful shutdown: the app handles SIGTERM, plus a short preStop sleep so the endpoint is removed from the load balancer before the process stops.
lifecycle:
  preStop:
    exec:
      command: ["sleep", "10"]
terminationGracePeriodSeconds: 40
  1. A PodDisruptionBudget and at least 3 replicas spread across zones.
  2. Backward-compatible API and DB changes so old and new versions can run side by side.

Why → Without the preStop delay, kube-proxy and the ALB can still send requests to a pod that has already received SIGTERM, giving a burst of 502s on every deploy.

Interview tip → Mention the 502 burst on deploys; it shows you have actually seen this in production.

All Real-World Interview questions Roadmap: Interview readiness

More on Deployments and releases