Zero-Downtime Deployments in Kubernetes

A
Author
21 Apr, 2026 1 min read 797 views

Kubernetes Deployments roll out new versions gradually by default. But "gradual" isn't automatically "zero downtime": dropped connections during shutdown are the usual culprit. These settings close the gaps.

1. Rolling update strategy

spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1          # one extra Pod during the rollout
      maxUnavailable: 0    # never go below 4 ready Pods
  minReadySeconds: 10      # a new Pod must stay ready this long before it counts

2. Readiness probes gate traffic

New Pods only receive traffic once their readiness probe passes. Without a readiness probe, Kubernetes sends requests to Pods that are still starting.

3. Shut down gracefully

When a Pod is terminated, Kubernetes sends SIGTERM and, at about the same time, starts removing it from load balancers. That removal takes a moment to propagate, so for a few seconds new requests can still arrive.

spec:
  terminationGracePeriodSeconds: 45
  containers:
    - name: api
      lifecycle:
        preStop:
          sleep:
            seconds: 10      # keep serving while endpoints update (older clusters: exec ["sleep","10"])

Then your app should handle SIGTERM: stop accepting new connections, finish in-flight requests, close database pools and exit before the grace period ends.

4. Protect against voluntary disruptions

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: api
spec:
  minAvailable: 3
  selector:
    matchLabels: { app: api }

Node upgrades and drains will wait rather than evict too many Pods at once.

5. Make releases backward compatible

  • During a rollout, old and new versions run side by side. Database migrations must work with both (expand first, contract later).
  • API changes must be compatible with clients still talking to the old version.

6. Watch, and be ready to roll back

kubectl rollout status deploy/api --timeout=5m || kubectl rollout undo deploy/api

For riskier changes, progressive delivery tools (Argo Rollouts, Flagger) automate canary releases with metric checks.

Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.