← Blog

Kubernetes · Reliability · Deployments

Why Can a “Successful” Kubernetes Rolling Deployment Still Drop Requests?

Kubernetes can report a successful rollout while users see 502s, 503s and connection resets. This article follows one request through Pod termination and covers what has to happen (draining, probes, grace periods, capacity) for a rollout to be zero-downtime in practice.

Aashaya Aryal

July 11, 2026 · 14 min read

Updated November 17, 2026

Traffic backed up across several highway lanes while an adjacent lane remains open.

The deployment finishes: deployment "checkout-api" successfully rolled out. Every new Pod shows READY 1/1 and Running, the old ReplicaSet scales to zero, and Kubernetes reports exactly the state you asked for. Yet during the rollout, production traffic logged a handful of 502s, 503s and connection resets.

That feels contradictory until you notice that two different questions are being answered. Kubernetes answers "did I replace the old Pods with healthy new ones?" Users care about "did every request keep flowing safely while that happened?"

A rollout involves a lot of moving parts: the Deployment controller, ReplicaSets, Pods, EndpointSlices, the kubelet, Service routing, possibly an external load balancer, the application process and its open TCP connections. They don't all change state at the same instant. When an old Pod starts terminating, Kubernetes updates its endpoint state and begins graceful shutdown, but a load balancer may take a while to notice, and existing connections can live longer still. If the process exits before that leftover traffic drains, the requests go with it.

So this article is about what has to stay true between the moment a Pod is marked for deletion and the moment its last request finishes.

What a rolling update guarantees

Deployments normally use the RollingUpdate strategy, controlled mainly by two settings:

YAML
strategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 25%
    maxSurge: 25%

maxUnavailable limits how many of the desired replicas may be unavailable during the rollout. maxSurge limits how many extra Pods may exist above the desired count. With four replicas, a rollout might go from 4 old, to 3 old and 2 new, to 2 old and 3 new, to 4 new:

Diagram

4 × v1

3 × v1
2 × v2

2 × v1
3 × v2

4 × v2

That gives the controller a capacity envelope for replacing Pods. It doesn't promise that requests complete. Even maxUnavailable: 0 doesn't mean zero failed requests. It means Kubernetes keeps enough Pods available according to the strategy. Whether a request that already reached an old Pod survives that Pod's termination is a separate problem. The Deployments documentation covers the strategy settings.

What happens when a Pod is terminated

Take three replicas behind a load balancer, and Kubernetes decides to terminate Pod A. Roughly, as described in the Pod lifecycle docs:

  1. The Pod gets a deletion timestamp.
  2. Its endpoint is marked as terminating and stops being "ready" for normal traffic.
  3. The kubelet starts shutting the Pod down: it runs any preStop hook, then sends SIGTERM.
  4. The Pod has a grace period (30 seconds by default) to exit.
  5. If it's still running after that, it's killed.

The important detail is that this isn't one atomic instruction delivered to everything that routes traffic. The change has to propagate.

Diagram
ClientPodLoad BalancerEndpointSliceKubernetesClientPodLoad BalancerEndpointSliceKubernetesRouting state propagatesPod deletion beginsEndpoint terminating / ready=falseNew requestRequest may still be associatedwith old backend / connectionShutdown continues

That's the central race: the application can exit faster than traffic stops arriving. Kubernetes already knows the endpoint is leaving, while another component still has a stale view, an open connection, or work in progress on the Pod. A safe rollout keeps the old instance alive long enough for the traffic path to catch up.

Endpoints, load balancers and open connections

An EndpointSlice is the object that lists which Pod IPs back a Service, along with conditions for each one: ready, serving and terminating (see the EndpointSlices docs). A terminating endpoint typically looks like this:

JSON
{
  "ready": false,
  "serving": true,
  "terminating": true
}

That combination means "don't send me new normal traffic, but I'm still alive and may be finishing work." It's deliberately different from "removed, process dead", and the gap is what lets load balancers and proxies drain connections. The Kubernetes tutorial Explore Termination Behavior for Pods and Their Endpoints walks through this transition.

An external load balancer is another system with its own idea of which backends are healthy:

Diagram

User

Cloud Load Balancer

Backend / NEG

Kubernetes Service

Pod

Several of those components keep their own version of "is this endpoint still available?", and they converge quickly but not instantly. Google's GKE Ingress configuration docs describe the concrete result: during scale-down with network endpoint groups, 502 errors happen when Pods are terminated before existing connections close, and 503 errors happen when traffic is sent to endpoints that have already been deleted. Their fix combines a load balancer drain timeout with a preStop hook that keeps the Pod alive.

HTTP keep-alive adds another wrinkle. Even after a load balancer stops opening new connections to a Pod, it may still hold an existing one. There may be no active request when termination starts, and then another request arrives on that connection a moment later. So draining can mean several things: stop accepting new connections, stop accepting new requests on connections that are being retired, let active requests finish, and close idle connections deliberately. Closing a listener and finishing requests are related but not the same.

Draining inside the application

SIGTERM isn't an instruction to vanish as fast as possible. If the application (or its framework) responds by closing everything and exiting, the process sees an orderly shutdown, but the timeline can look like this:

TimeWhat happens
T+0 msPod termination begins
T+20 msApplication exits
T+300 msRouting changes still propagating
T+500 msAn old keep-alive connection sends the next request

The process is gone; the connection isn't. A better sequence is: receive the signal, stop accepting new work, stay alive, let active requests finish, close connections, then exit. The key word is drain.

The simplest tool for buying propagation time is a preStop hook, which runs before Kubernetes sends SIGTERM:

YAML
spec:
  terminationGracePeriodSeconds: 60
  containers:
    - name: checkout-api
      image: example/checkout:42
      lifecycle:
        preStop:
          exec:
            command:
              - /bin/sh
              - -c
              - sleep 15

A plain sleep 15 isn't sophisticated, but it does something useful: the Pod is marked for deletion, routing systems get time to stop choosing it, and the process stays alive until then. GKE's guidance uses this approach.

The right number depends on your traffic path. Don't copy sleep 120 because one example used it; measure how long endpoint removal and draining actually take for you. A fixed sleep is also blind in both directions. If removal normally takes 2 seconds and the hook sleeps 20, you waste 18 seconds on every termination. If a load balancer event occasionally takes 35 seconds, 20 isn't enough. Application-aware draining is more precise where it's practical; a fixed delay stays popular because it's simple, predictable and easy to test.

An application can also make its own lifecycle explicit, moving from running to draining to terminated. While draining, /ready returns 503, /live keeps returning 200, existing requests continue, and new expensive work is refused. In Spring that can be as small as:

JAVA
@Component
public class DrainState {
    private final AtomicBoolean draining =
        new AtomicBoolean(false);

    public void startDraining() {
        draining.set(true);
    }

    public boolean isDraining() {
        return draining.get();
    }
}
JAVA
@GetMapping("/ready")
public ResponseEntity<Void> ready() {
    if (drainState.isDraining()) {
        return ResponseEntity
            .status(503)
            .build();
    }

    return ResponseEntity.ok().build();
}

Kubernetes already marks terminating endpoints as not ready for Service traffic, so this isn't about telling Kubernetes that deletion started. Its value is in controlling new application work, exposing drain progress, finishing in-flight operations and coordinating anything outside Kubernetes. Kubernetes manages the endpoint lifecycle; the application still owns what "done" means for its own work.

The grace period is a budget

A Pod doesn't get unlimited time to shut down. terminationGracePeriodSeconds (default 30) covers the preStop hook and the application's shutdown, and anything still running afterwards is killed. So it's best thought of as a budget:

grace period ≥ preStop + application shutdown + safety margin

If your load balancer has its own drain requirements, those have to fit too. A configuration with a 20-second preStop, requests that can take 45 seconds and a 30-second grace period contains a contradiction: some valid requests can't possibly finish.

Long requests force a design decision. If POST /reports/export can take 45 seconds and termination starts two seconds after it begins, a 30-second budget won't cover it. The options are a longer shutdown window, making the work asynchronous, supporting cancellation and resumption, or making the request safely retryable. Long-running synchronous work and a short deployment lifecycle are both assumptions, and they need to agree.

Readiness, liveness and startup probes

Kubernetes has three kinds of health probe, and treating them as interchangeable can turn a normal slowdown into an outage. The probes documentation describes each.

A readiness probe asks: should this instance receive production traffic right now? A container can be alive but not ready, and that's fine; it may be temporarily unable to take work without needing a restart.

YAML
readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  periodSeconds: 5
  failureThreshold: 2

A liveness probe asks something more drastic: is this process broken in a way that restarting will fix? Repeated failures restart the container. The Kubernetes docs warn that badly designed liveness probes can cause cascading failures: containers get restarted under heavy load, the remaining Pods take on more traffic, and they fail too.

Diagram

Traffic Spike

Pod Overloaded

Liveness Probe Times Out

Pod Restarted

Fewer Serving Pods

More Load per Remaining Pod

A common version of this is making /live depend on downstream services. If liveness fails whenever PostgreSQL is unreachable, a database outage restarts the entire API fleet. That doesn't fix PostgreSQL, and it adds connection storms, cold caches, JVM warm-up and fresh DNS and TLS connections to the incident. Liveness should reflect whether restarting this container is likely to help. Readiness can be more sensitive to temporary trouble.

A startup probe protects slow initialisation. If a Spring service needs 60 seconds to start and liveness checks begin too early, the container can be restarted over and over without ever finishing startup. A startup probe with failureThreshold: 30 and periodSeconds: 5 gives it up to 150 seconds before liveness takes over.

Readiness should mean ready for production, not just that a port is open. If /ready returns 200 the moment the HTTP server binds, the Pod may still be warming caches, loading reference data, filling connection pools or JIT-compiling hot paths. The rollout then swaps warm instances for cold ones that claim to be ready:

Diagram

terminated

Warm v1

Cold v2
Ready=true

Production Traffic

Gone

The Deployment succeeds and latency spikes. Readiness should mean the instance can handle real traffic at acceptable latency.

Readiness keeps running after startup, which is useful but needs care. If every Pod marks itself unready when its connection pool gets busy, a traffic spike can take Pod A out, push its load onto B, take B out, and leave C with everything until it goes too. A protective mechanism has removed the whole fleet. Readiness thresholds have to make sense for the system, not just one process.

Capacity during a rollout

A rollout can follow its strategy exactly and still overload the service. Say you run 4 replicas, each handling 250 requests per second, so 1,000 total, with 850 of real traffic. If the strategy allows one Pod to be unavailable, serving capacity drops to 750 during the rollout while traffic stays at 850:

Diagram

850 req/s

Pod A
250

Pod B
250

Pod C
250

Pod D
Unavailable During Rollout

maxUnavailable doesn't know how much headroom you have. For a small latency-sensitive service, maxUnavailable: 0 with maxSurge: 1 starts a new Pod before retiring an old one, so you go 4 old → 4 old + 1 new → 3 old + 2 new and so on.

Surge capacity isn't free either. Each extra Pod needs CPU and memory and opens its own database, Kafka and cache connections. If every Pod opens 30 database connections, surging several at once can put pressure on PostgreSQL while the HTTP tier looks safer. Ten Pods starting together with 50 connections each ask the database for 500 connections at once. The same applies to Redis, Kafka, DNS, TLS handshakes and configuration services. Adding application Pods doesn't add capacity to the shared dependencies, so rollout headroom has to be checked end to end.

Streams, workers and sidecars

HTTP request/response traffic is only one kind of work.

Long-lived connections like WebSockets, server-sent events and gRPC streams may never end on their own, so waiting for them would make rollouts impractical. A drain policy might stop accepting new streams, tell clients to reconnect, allow a short grace period, close what's left and let clients reconnect to another Pod. That needs client cooperation: for these protocols, a graceful rollout is a contract between server and client.

Background workers need their own shutdown order. A Kafka consumer that exits immediately on SIGTERM can leave an event half-processed. A safer sequence is: stop polling for new records, finish the current batch, commit offsets, close the consumer, exit, all within the grace period.

Sidecars add another ordering problem. If a Pod runs the application alongside a service-mesh proxy, and the proxy exits before the application finishes its outgoing calls, the application is still alive but can't complete its work. Newer Kubernetes versions have improved sidecar lifecycle handling, but the general point holds: a Pod can contain several processes whose shutdown order affects correctness.

PodDisruptionBudgets

A PodDisruptionBudget (PDB) limits how many Pods can be taken down at once by voluntary disruptions such as node drains:

YAML
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: checkout-api
spec:
  minAvailable: 3
  selector:
    matchLabels:
      app: checkout-api

For a four-replica service, this says voluntary evictions should leave at least three available. It doesn't mean Pods can't disappear: hardware failures, kernel crashes, network loss, out-of-memory kills and power loss don't consult the PDB. The disruptions documentation explains the difference between voluntary and involuntary disruptions.

PDBs and maxUnavailable look similar but govern different paths. Rolling-update settings control how the Deployment replaces its own Pods. A PDB constrains eviction workflows like node drains. A production service often needs both.

When shutdown isn't graceful

Everything above assumes Kubernetes gets to run an orderly shutdown. Real failures include nodes vanishing, VMs losing power, kernel panics, network partitions and process crashes, with no preStop, no drain window and no SIGTERM. Graceful shutdown improves planned events. It doesn't replace the mechanisms that keep work correct when an instance disappears without warning: idempotency, retries, transactional boundaries and reconciliation.

For the same reason, don't put essential state only in shutdown hooks. If correctness depends on flushing something on SIGTERM, a power loss skips it. Shutdown hooks are for draining, cleanup and closing resources; critical state should already be durable before termination begins.

Testing and observing rollouts

kubectl rollout restart followed by kubectl rollout status tests whether Kubernetes can finish a rollout. It doesn't test the request lifecycle. A better experiment keeps traffic flowing while you roll the service repeatedly: say, 100 normal requests per second, a few 10-second requests and some persistent keep-alive connections. Then measure HTTP errors, connection resets, p95 and p99 latency, whether in-flight requests completed, active connection counts, Pod termination timing and EndpointSlice state. That tests the real promise, "a deployment shouldn't break user requests", rather than "the deployment eventually became ready".

You can watch endpoints change during a rollout:

BASH
kubectl get endpointslices \
  -l kubernetes.io/service-name=checkout-api \
  -o yaml

A terminating endpoint shows ready: false, serving: true, terminating: true, while its replacement shows ready: true, serving: true, terminating: false. Seeing that in a real rollout makes the handoff much easier to understand than a diagram.

If graceful shutdown matters for availability, shutdown deserves telemetry of its own. I'd log lifecycle events with active request counts at each step:

JSON
{
  "event": "shutdown_started",
  "pod": "checkout-7c84d",
  "activeRequests": 17
}

followed by readiness_disabled, periodic shutdown_drain_progress, and finally shutdown_complete with the duration. Useful metrics are shutdown duration, requests active when shutdown started, requests completed during drain, requests aborted, and how often Pods are force-killed. Those answer questions a normal Deployment dashboard can't: how long does drain usually take, do Pods reach zero active requests, and do rollout errors line up with a particular shutdown stage?

Putting it together

For a latency-sensitive HTTP service, a reasonable starting point might look like this:

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: checkout-api
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  template:
    metadata:
      labels:
        app: checkout-api
    spec:
      terminationGracePeriodSeconds: 60
      containers:
        - name: app
          image: checkout-api:42
          ports:
            - containerPort: 8080
          startupProbe:
            httpGet:
              path: /startup
              port: 8080
            periodSeconds: 5
            failureThreshold: 24
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            periodSeconds: 5
            failureThreshold: 2
          livenessProbe:
            httpGet:
              path: /live
              port: 8080
            periodSeconds: 10
            failureThreshold: 3
          lifecycle:
            preStop:
              exec:
                command:
                  - /bin/sh
                  - -c
                  - sleep 10

It isn't a universal template. What matters is being able to say why each value is there:

SettingQuestion it answers
maxUnavailableHow much serving capacity can safely disappear?
maxSurgeHow much temporary extra load on dependencies is safe?
startupProbeHow long does real startup take?
readinessProbeWhen can this instance take production traffic?
livenessProbeWhen would a restart actually help?
preStopHow long do routing changes and draining take?
terminationGracePeriodSecondsHow long can the whole shutdown take?

The patterns I watch for are the ones that collapse these into one crude signal: liveness and readiness pointing at the same /health endpoint; readiness that turns true when the port opens; exiting immediately on SIGTERM; a grace period shorter than legitimate requests; a huge preStop sleep nobody measured; assuming a PDB prevents downtime; and treating kubectl rollout status as proof of zero customer-visible errors.

A healthy termination looks like this:

Diagram
ClientLoad BalancerApplicationEndpoint RoutingKubernetesClientLoad BalancerApplicationEndpoint RoutingKubernetesPropagate backend changeTermination beginsEndpoint terminating / ready=falseEnter drain modeExisting / racing trafficRequestComplete successfullyStop selecting old backendActive requests reach zeroClose resources and exit

The unsafe version changes just one ordering:

Diagram
ClientLoad BalancerApplicationEndpoint RoutingKubernetesClientLoad BalancerApplicationEndpoint RoutingKubernetesRouting state still convergingTermination beginsEndpoint update startsExit immediatelyRequestBackend gone502 / reset

That one difference is how a Deployment can be technically successful while requests still fail. Kubernetes replaced the Pod correctly; the traffic handoff just wasn't finished when the process left.

Key takeaways

  • A successful rollout means Pods were replaced, not that every request completed. Test rollouts with real traffic running.
  • Keep terminating Pods alive long enough for endpoint and load balancer changes to propagate, using a measured preStop delay or application-aware draining.
  • Treat terminationGracePeriodSeconds as a budget that has to cover preStop, draining and your longest legitimate request.
  • Give readiness, liveness and startup probes different jobs. Don't make liveness depend on downstream services, and don't report ready before the instance can handle real load.
  • Check rollout headroom end to end: maxUnavailable can cut capacity, and maxSurge can overload shared dependencies.
  • Plan draining for streams, background workers and sidecars, and never rely on shutdown hooks for correctness.

References