To troubleshoot pods, we sometimes need to access them directly from the local host as it is the case for the below "nginx" pod.
The Below file is the Yaml configuration file of a pod that "houses" a container that is running an "nginx" application listening on port "80":
We create our pod using the below command:
On already running pods, we could use the below command:
The next step is to make all the requests arriving on the host on port "88" be forwarded to the "nginx" container on port "80" using the below command:
We could check the if the "nginx" web server is running properly by sending a "HTTP GET" request to it for example using the below command:
We could run the "kubectl port-forward" on the deployment or the service backing the pods we want to debug, by simply replacing the pod's name by the deployment's or the service's name as we can see below with the deployment: