The application returns 502 from the ALB intermittently after each deploy. Fix it.

AdvancedHands-onLive debugging tasks
Answer
aws elbv2 describe-target-health --target-group-arn "$TG_ARN"
kubectl get deploy api -o jsonpath='{.spec.template.spec.containers[0].lifecycle}'
kubectl get deploy api -o jsonpath='{.spec.template.spec.terminationGracePeriodSeconds}'

Cause: pods are killed while the ALB still sends them traffic. Deregistration lags behind pod termination. Fix: add a preStop sleep (10–15s), make terminationGracePeriodSeconds larger than the sleep plus drain time, use pod readiness gates with the AWS Load Balancer Controller, and handle SIGTERM gracefully in the app. Also check that the app's keep-alive timeout is longer than the ALB idle timeout (60s default).

Key trick → 502s that appear only during deploys are almost always a termination race. 502s at random are often a keep-alive mismatch, where the app closes idle connections before the ALB does.

All Real-World Interview questions Roadmap: Interview readiness

More on Live debugging tasks