Peak-traffic deploys used to mean a maintenance window and hoping nobody noticed. Kubernetes makes zero-downtime kubernetes deployments realistic, but only with a deliberate rollout configuration. A new image does trigger a rolling update by default, yet requests can still land on pods that are shutting down, or on fresh pods not yet able to serve traffic.
This guide covers the four pieces that hold traffic together during a release: a rolling update strategy with explicit surge and unavailable limits, readiness probes that gate traffic, PodDisruptionBudgets against voluntary evictions, and graceful shutdown hooks so in-flight requests finish. It closes with blue-green and canary patterns for riskier releases. Every YAML snippet below is ready to adapt to your cluster.
Why Deployments Drop Traffic
Most release-time outages come from three gaps, not from Kubernetes itself. First, old pods get killed while still handling requests. Kubernetes sends SIGTERM and waits terminationGracePeriodSeconds (30 seconds by default), but if your app ignores the signal or the grace period is too short, connections die mid-response. Second, new pods start receiving traffic before they are actually ready. Without a readiness probe, the Service adds a pod to endpoints the moment the container starts, even if your app still needs 20 seconds to warm its cache or connect to the database. Third, cluster operations evict pods at the worst moment: node upgrades, autoscaler scale-downs, and manual drains all count as voluntary disruptions a rollout does not block on its own.
Fixing all three is mechanical. The sections below take them in order.
Rolling Updates: The Engine of Zero-Downtime Kubernetes Deployments
A Kubernetes rolling update replaces pods gradually instead of all at once. You control the pace with two fields on the Deployment strategy: maxSurge (extra pods allowed above the replica count) and maxUnavailable (pods that may be down at once). For a typical API with six replicas, a safe starting point:
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 6
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # spin up 2 extra pods before killing old ones
maxUnavailable: 1 # never take more than 1 pod out of service
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: registry.example.com/api:v2.4.0
ports:
- containerPort: 8080
With maxUnavailable: 1, five of six pods keep serving traffic through the rollout, and maxSurge: 2 lets the scheduler start replacements early so capacity never dips. Keep maxUnavailable low for user-facing services; 25% (the default) is too aggressive for small replica counts. Wrap this in an automated pipeline so every release follows the same path: our GitHub Actions CI/CD pipeline walkthrough shows the full build, test, and deploy flow behind these rollouts.
Gate Traffic With Readiness Probes
Readiness probes decide when a pod is allowed to receive traffic. Until the probe succeeds, kubelet keeps the pod out of the Service endpoints, which prevents the “fresh pod, broken responses” problem. A solid readiness probe configuration has three properties: an endpoint reflecting real readiness (a /ready handler checking the database connection, not just /), enough startup time, and re-checks frequent enough to catch a pod that degrades later:
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
Do not point readiness and liveness at the same check with the same thresholds. Liveness restarts a stuck container; readiness only removes it from traffic. If a dependency outage trips a shared probe, liveness restarts every pod in a loop and turns a partial outage into a full one. Keep them separate, and keep the readiness check strict about what “ready” means.
Protect Voluntary Disruptions With PodDisruptionBudgets
Rolling updates are not the only thing that removes pods. Node upgrades, autoscaler scale-downs, and kubectl drain all evict pods, and during a deploy those evictions stack on top of your rollout. Pod disruption budgets set a floor: they tell the cluster how many pods must stay available, and the eviction API refuses to proceed when draining one more pod would break it.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 4
selector:
matchLabels:
app: api
For a six-replica service, minAvailable: 4 means the cluster can evict at most two pods at a time. Combined with the rolling update limits above, no single operation — deploy or maintenance — can take the service below four healthy pods. Apply a PDB to every stateful or user-facing workload before you need it, not after the first bad drain.
Drain Nodes Safely During Upgrades
When upgrading nodes, drain them with flags that respect what is running:
kubectl drain worker-3 --ignore-daemonsets --delete-emptydir-data --timeout=120s
The --timeout flag matters: without it, a stuck pod blocks the drain forever. With a PDB in place, the drain pauses instead of violating your availability floor. After the upgrade, kubectl uncordon worker-3 returns the node to scheduling. Upgrade one node at a time and watch kubectl get pdb to confirm budgets stay satisfied throughout.
Blue-Green and Canary for Riskier Releases
Rolling updates suit routine releases, but some changes deserve more caution: database migrations, major dependency upgrades, rewrites of hot paths. Two patterns help. In blue-green you run the new version (green) alongside the old (blue) at full scale, verify with mirrored traffic or smoke tests, then flip the Service selector in one step. Rollback is instant: flip the selector back. In canary you route a small slice of traffic, say 5%, to the new version first, watch error rates and latency, then ramp up in stages.
Canary routing usually happens at the ingress layer with weighted backends; our ingress controller comparison covers which controllers support traffic splitting. For when to pick which pattern, read our blue-green vs canary strategy guide. Tools like Argo Rollouts or Flink/Flagger automate the staged analysis, but the selector flip and the weighted route are the core mechanics, both plain Kubernetes objects you can manage by hand first.
Handle SIGTERM Gracefully With preStop Hooks
When Kubernetes stops a pod it sends SIGTERM, waits out the grace period, then sends SIGKILL. Many apps need a moment to finish in-flight requests and close connections. A preStop hook buys that time and runs before SIGTERM is delivered:
spec:
terminationGracePeriodSeconds: 60
containers:
- name: api
image: registry.example.com/api:v2.4.0
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 15"]
The sleep gives the Service time to remove the pod from endpoints (endpoint propagation takes a few seconds) before the app starts shutting down. Fifteen seconds covers most propagation delays; raise it if your cluster is large. Also confirm your app actually handles SIGTERM. A Node.js server needs an explicit process.on('SIGTERM') handler calling server.close(); a Go http.Server needs Shutdown() wired to signal handling. Without that, the grace period is wasted and requests still die.
Verify the Rollout Before You Call It Done
Never trust “deployment applied” as proof. Watch the rollout itself:
kubectl rollout status deployment/api --timeout=5m
kubectl rollout history deployment/api
kubectl get endpoints api -w
rollout status blocks until the new ReplicaSet is fully available or the timeout hits. Watching endpoints confirms new pod IPs join the Service. If something looks wrong, kubectl rollout undo deployment/api returns to the previous ReplicaSet in seconds — the fastest rollback path Kubernetes offers. If you manage manifests declaratively, Argo CD can automate and gate these rollouts with sync waves and health checks; see our GitOps with Argo CD guide.
Common Mistakes That Break Zero Downtime
- maxUnavailable too high. The 25% default kills two of eight pods at once. Set an absolute number for small services.
- Readiness probe missing or trivial. A probe that returns 200 before the app can serve traffic is the same as no probe.
- Shared readiness and liveness checks. One dependency blip restarts your whole fleet instead of just pausing traffic.
- No PodDisruptionBudget. The first node upgrade during a deploy teaches this lesson the hard way.
- App ignores SIGTERM. The grace period only helps if the process handles the signal and drains connections.
- Capacity dips mid-deploy. Pair rollouts with the HorizontalPodAutoscaler so a traffic spike during a release does not leave you short on replicas.
Start with the rolling update strategy and readiness probes; those two fix the majority of deploy-time outages. Add the PDB and graceful shutdown handling next, and reach for blue-green or canary only when the release risk justifies the extra moving parts. Run kubectl rollout status after every deploy until the pattern is boring, because boring deploys are the goal.