Every deploy causes 10–20 seconds of 502s from the ALB, even with a rolling update.

IntermediateTroubleshooting5xx errors
Answer

Likely causes → Kubernetes sends SIGTERM and removes the endpoint at the same time, but the ALB (via the AWS Load Balancer Controller) takes several seconds to deregister the target. Meanwhile the app has already exited, so in-flight and new requests hit a dead pod.

Diagnose → ALB access logs during the deploy show 502 with target_status_code=- for pods that were terminating.

Fix →

lifecycle:
  preStop:
    exec: { command: ["sleep", "20"] }
terminationGracePeriodSeconds: 45

Also make the app drain on SIGTERM, and tune the target group's deregistration_delay.timeout_seconds.

Prevent → Enable pod readiness gates with the AWS Load Balancer Controller so new pods receive traffic only after the ALB marks them healthy, and run a load test during a deploy in staging.

All Real-World Interview questions Roadmap: Interview readiness

More on 5xx errors