We might deploy a something to a pod which doesn’t have an external interface or we just want to debug our deployed pod without going through load balancers etc. Kubernetes allows us to essentially connect and redirect a pod via it’s port, so for example I might have pod name “my-pod” on port 5000 within Kubernetes. I want to access this via curl or a browser or whatever.
Hence we use the following command
kubectl port-forward pod/my-pod 8080:5000
and now to access the application running in this pod using something like this
curl localhost:8080