FULL AI ANALYSIS

Kubernetes rolling update causes 503s: long preStop hook and readiness removal drop in-flight requests

Generated Oct 26, 2026, 9:23:15 AM

Analysis summary

503s during rolling updates indicate ingress still routing to pods that are no longer ready to accept new traffic while preStop holds SIGTERM. Root causes: preStop running before the pod informs the readiness gate/ingress to stop sending traffic; the readinessProbe continues returning 200 during preStop; Ingress healthchecks mark backend unhealthy slowly; and lack of a coordinated graceful shutdown endpoint. Best practice is to make the application respond to SIGTERM by immediately failing readiness and stop accepting new connections, while background cleanup continues asynchronously, and to use readinessGate or lifecycle hooks to coordinate with the controller.

Possible causes

Application doesn't fail readiness or close listener immediately on SIGTERM; preStop holds long cleanup while load balancer continues routing

90%

preStop executes before readiness change; preStop script itself doesn't trigger readinessProbe failure

70%

Ingress health check interval or slow upstream health detection causes lag in removing pod from rotation

50%

Rolling update parameters (maxUnavailable/maxSurge) too aggressive for traffic pattern

30%

Suggested fixes

1

Diagnostic step 1

Update application to handle SIGTERM by: (a) closing the HTTP listener or immediately returning non-200 on readiness endpoint, and (b) finishing cleanup asynchronously before exit. Deploy this change in a canary first.

2

Diagnostic step 2

Use readinessGate or add an explicit 'drain' readiness endpoint: on SIGTERM set readiness false immediately, which signals kubelet and ingress to stop routing new traffic.

3

Diagnostic step 3

Increase terminationGracePeriodSeconds to allow background cleanup, and tune Ingress healthcheck intervals to detect readiness change faster if safe.

4

Diagnostic step 4

Test in staging by sending continuous traffic while performing rollout and observe that in-flight requests finish and 503s no longer appear.

5

Diagnostic step 5

If application cannot close listener quickly, implement client-side retries or a preStop that notifies a sidecar to mark pod not ready before heavy cleanup starts.