Every rolling deploy produces a short burst of 502s on the AWS ALB.
IntermediateTroubleshootingReliability Patterns in Production
Answer
Likely causes → Pods terminate before the ALB stops sending traffic: no preStop delay, app exits immediately on SIGTERM, or deregistration delay is longer than terminationGracePeriodSeconds. ALB access logs show elb_status_code 502 with target_status_code -.
Diagnose →
kubectl get deploy checkout -n shop -o yaml | yq '.spec.template.spec | {grace: .terminationGracePeriodSeconds, lifecycle: .containers[0].lifecycle}'
kubectl get ingress -n shop checkout -o yaml | grep -i deregistration
Fix → Add preStop: sleep 15, handle SIGTERM gracefully, set terminationGracePeriodSeconds above preStop plus drain time, and align the target group deregistration_delay.timeout_seconds. With the AWS Load Balancer Controller, enable pod readiness gates.
Prevent → Run a pod-kill chaos experiment under load after any change to deployment settings.
More on Reliability Patterns in Production
Clients get 503s with body `upstream connect error or disconnect/reset before headers. reset reason: overflow`, and Envoy logs show flag `UO`.AdvancedNGINX ingress returns 504 and logs `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAfter a 30-second database blip, Postgres keeps rejecting connections with `FATAL: sorry, too many clients already` for 20 minutes.AdvancedCustomers were charged twice during an incident where the payment API timed out.AdvancedRedis restarted and immediately the database CPU hit 100% and the site went down.AdvancedLogs fill with `CallNotPermittedException: CircuitBreaker 'inventory' is OPEN and does not permit further calls` long after inventory recovered.Intermediate