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.

All Real-World Interview questions Roadmap: Interview readiness

More on Live debugging tasks