Wednesday, November 14, 2018

Access K8S Pod Service Port via Kubectl Port-forward on Remote Workstation

Requirement:

     We would like to access the service of a Pod from a remote desktop. ie  there is pod running nginx with port 80 in Oracle OCI K8S. We would like to access it on local windows 10 desktop.
We can use kubectl port forward  via internet. The workstation can be in company intranet behind firewall. As long as "kubectl get nodes" (kubectl can access API server) works via proxy or ssh tunnel,  we can use our local workstation to access the remote pod. This command can be very useful in troubleshooting scenarios

Solution:

$ kubectl port-forward <POD_NAME >  8081:80
Forwarding from 127.0.0.1:8081 -> 80
Forwarding from [::1]:8081 -> 80

Open a new window
curl --head http://127.0.0.1:8081

We should get page from the POD

No comments: