The Service returns "connection refused" but pods are Running. Debug it.
IntermediateHands-onLive debugging tasks
Answer
kubectl get endpointslices -l kubernetes.io/service-name=api # empty = selector mismatch or pods not Ready
kubectl get svc api -o yaml | grep -A5 -E 'selector|ports'
kubectl get pods -l app=api -o wide
kubectl run tmp --rm -it --image=nicolaka/netshoot -- bash
# curl -v http://api:80/health # via Service
# curl -v http://<pod-ip>:8080/health # direct to pod
kubectl exec api-xyz -- ss -ltn # is the app listening on 0.0.0.0:8080 or only 127.0.0.1?
Key trick → Test pod IP directly, then the Service. If the pod IP works but the Service doesn't, it's the selector or targetPort. If the pod IP fails too, the app is bound to 127.0.0.1 or listening on the wrong port.
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?AdvancedA Docker container exits immediately after `docker run -d`. Find out why.Beginner`docker build` fails with "COPY failed: file not found in build context". Fix it.Beginner