How do you reach a pod from your laptop for debugging without exposing it?
BeginnerScenarioKubernetes Networking
Answer
Situation read → kubectl port-forward tunnels through the API server.
What I'd do →
- Run
kubectl port-forward pod/web-7d4f 8080:80orsvc/web 8080:80 - Open
http://localhost:8080 - It is a debugging tool, not for production traffic
- Use
kubectl execor an ephemeral debug container:kubectl debug -it pod/web --image=nicolaka/netshoot --target=web
Why → The tunnel uses the API server connection, so no extra network path is needed.
Interview tip → Say netshoot is your network toolbox in Kubernetes.
More on Kubernetes Networking
Explain the Kubernetes networking model in one minute.BeginnerClusterIP, NodePort and LoadBalancer: when do you use each?BeginnerHow does a pod find another service by name?BeginnerService versus Ingress: what is the difference?BeginnerWhat does a CNI plugin do and which ones do you know?BeginnerBy default, can any pod talk to any other pod, and how do you change that?Beginner