Interview Prep/Kubernetes/Services, Ingress and DNS

How do you test a Service quickly without exposing it?

BeginnerScenarioServices, Ingress and DNS
Answer

Situation read → A developer wants to hit an internal service from a laptop.

What I'd do →

  1. kubectl port-forward svc/web 8080:80
  2. curl localhost:8080
  3. For a pod use kubectl port-forward pod/web-abc 8080:8080
  4. Use kubectl exec to curl from inside when the issue is in-cluster only
  5. Stop with Ctrl+C

Why → port-forward tunnels through the API server to a pod, so no Service or LB changes are needed.

Interview tip → Mention that port-forward to a Service picks one pod and does not load balance.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Ingress and DNS