Interview Prep/Kubernetes/Resources, OOM, probes and termination

Pods restart every few minutes with `Liveness probe failed: Get "http://10.0.3.17:8080/healthz": context deadline exceeded (Client.Timeout exceeded while awaiting headers)`.

IntermediateTroubleshootingResources, OOM, probes and termination
Answer

Likely causes → The health endpoint is slower than timeoutSeconds (default 1s) under load or during GC pauses, or it checks dependencies (DB, Redis) so a slow dependency kills every Pod. Liveness kills turn a slowdown into an outage.

Diagnose →

kubectl get deploy api -o jsonpath='{.spec.template.spec.containers[0].livenessProbe}' | jq
kubectl exec api-x -- sh -c 'time wget -qO- localhost:8080/healthz'
kubectl get events --field-selector reason=Unhealthy -n api

Fix → Make liveness a cheap in-process check with no dependency calls, and give it room:

livenessProbe:
  httpGet: {path: /livez, port: 8080}
  periodSeconds: 10
  timeoutSeconds: 3
  failureThreshold: 6

Prevent → Liveness answers "is the process wedged?", readiness answers "can I take traffic?". Never put dependency checks in liveness.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, OOM, probes and termination