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.
More on Live debugging tasks
A pod is in CrashLoopBackOff. You have 10 minutes. Walk through your commands.BeginnerThe pod shows `OOMKilled`. Diagnose and fix it.BeginnerA pod is stuck in `ImagePullBackOff`. Fix it.BeginnerA pod is `Pending` forever. What do you check?AdvancedThe Service returns "connection refused" but pods are Running. Debug it.IntermediateA Docker container exits immediately after `docker run -d`. Find out why.Beginner