1

I am attempting to reverse port forward information from a Kubernetes pod 192.168.49.2:30085 to my locoalhost:8000 but I am having issues.

The goal is to get the same response as curl 192.168.49.2:30085 on localhost:8000

One thing I have tried has been using ktunnel with the command ktunnel expose <service_name> 30085:8000 to try to forward this info. Doing this I get the output

INFO[0000] Exposed service's cluster ip is: 10.101.77.99
.INFO[0000] waiting for deployment to be ready
.....
INFO[0001] port forwarding to https://192.168.49.2:8443/api/v1/namespaces/default/pods/thisisatest-59d5584c84-b5qrc/portforward
INFO[0001] Waiting for port forward to finish
INFO[0001] Forwarding from 127.0.0.1:28688 -> 28688
INFO[2022-08-03 20:23:48.605] starting tcp tunnel from source 30085 to target 8000

Which seems normal and I am able to get a response when using curl http://10.101.77.99:30085 on local host 8000 but not the correct response.

I have also attempted to run a tcp server with the command nc 127.0.0.1 8000 | kubectl exec -i <pod_name> tcpserver 127.0.0.1 30085 cat But am having poor results as well. Am I using these services incorrectly? Or is there a better way to do this all together?

2 Answers 2

1

If you have access to kubectl, try

kubectl port-forward service/<servicename> 8000:30085.

0

Expose SSH on the pod and use SSH to do the reverse port forward

or

Use a service on the cluster pointing at your machine but that assumes the networking is connected some how

Those 2 anwsers were taken from this duplicate question. https://stackoverflow.com/questions/66666273/forward-traffic-from-kubernetes-pod-to-local-server

I think a third better approach might be to use somekinda mesh VPN like https://tailscale.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.