Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

`kubectl port-forward svc/web 8080:80` fails with `error: unable to forward port because pod is not running. Current status=Pending`.

BeginnerTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → port-forward to a Service actually picks one backing Pod; if the chosen Pod is not Running, it fails. It does not load balance and does not use the Service's endpoints readiness.

Diagnose →

kubectl get pods -l app=web

Fix → Fix the Pending Pod, or forward to a specific running Pod: kubectl port-forward pod/web-abc 8080:8080. Remember the right side is the Service port when targeting svc/, mapped to the targetPort.

Prevent → Use port-forward for debugging only, not as an access path.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy