
Proxy
Since this is an HTTP-based application, we can also use the kubectl proxy command to get access to the responses from our code:
kubectl proxy
And the output will show something akin to the following:
Starting to serve on 127.0.0.1:8001
As a reminder, you won't get a prompt back in the Terminal window until the proxy terminates. Just as with the Python example, we can determine the URL to use that the proxy will use to forward to our container based on the Pod name and the namespace that we used when invoking the kubectl run command. Since we did not specify a namespace, it used the default, which is called default. The URL pattern for accessing the Pod is the same as the Python example:
http://localhost:8001/api/v1/proxy/namespaces/<NAME_OF_NAMESPACE>/pods/<POD_NAME>/
And in the case of our Pod, this would be:
http://localhost:8001/api/v1/proxy/namespaces/default/pods/nodejs-568183341-2bw5v/
If you open a URL in your browser created with the Pod name that your Kubernetes cluster assigned, it should show you the same output that you saw using the port-forward command.