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 →
kubectl port-forward svc/web 8080:80curl localhost:8080- For a pod use
kubectl port-forward pod/web-abc 8080:8080 - Use
kubectl execto curl from inside when the issue is in-cluster only - 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.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate