Q: A stateless web application runs on Kubernetes. During a deployment of a new image, users report intermittent HTTP 502 Bad Gateway errors for a few seconds. What is missing in the Pod configuration?
Two core settings are likely missing or misconfigured:
Want to master this scenario in a live sandbox? The Linux Foundation's Certified System Administrator (LFCS) & SRE Track covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "Senior DevOps is about building reliable automated feedback loops between code commit and production observability. The interviewer is testing: Readiness probes, graceful shutdown, zero-downtime deployments.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Initial Diagnostics & Root Cause Analysis
Two core settings are likely missing or misconfigured:
- Readiness Probes: The new container starts, and Kubernetes instantly sends traffic to it before the internal application framework (like Spring Boot or Node.js) has fully initialized its HTTP listeners. A
readinessProbeensures the Service doesn't route traffic to the Pod until a specific path (e.g.,/health) returns HTTP 200. - Graceful Shutdown (SIGTERM handling): When the old Pod is deleted, Kubernetes sends a SIGTERM. If the application exits instantly, any requests currently in flight are abruptly dropped (HTTP 502). The application must catch the SIGTERM, stop accepting new connections, finish processing in-flight requests, and gracefully exit.
Remediation & Permanent Safeguards
- Readiness Probes: The new container starts, and Kubernetes instantly sends traffic to it before t...
- Graceful Shutdown (SIGTERM handling): When the old Pod is deleted, Kubernetes sends a SIGTERM. If...
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Confusing ALB 502 Bad Gateway (target connection reset) with 504 Gateway Timeout (upstream response timeout) when configuring General stateless application 502 indicates the backend target closed the TCP connection prematurely or returned malformed HTTP, whereas 504 means the target failed to respond before idle timeout.
- Setting target deregistration delay to zero instead of allowing connection draining when configuring General stateless application Instant target deregistration severs in-flight HTTP requests during auto-scaling scale-in or rolling deployments, causing immediate user-facing drops.
-
Failing to query CloudWatch ELB metrics (
HTTPCode_ELB_5XXvsHTTPCode_Target_5XX) during load balancer outages when configuring General stateless application Comparing load balancer generated errors against target generated errors immediately isolates whether the issue lies in the proxy tier or application runtime. - Overlooking Security Group rules on backend EC2/ECS instances that block health check traffic from the ALB when configuring General stateless application Target instances must explicitly permit inbound HTTP/HTTPS traffic from the ALB security group on the configured container/application port.