What is the best way to reverse port forward information from a Kubernetes cluster to localhost?
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:30085on localhost:8000
One thing I have tried has been using https://github.com/omrikiei/ktunnel with the command
ktunnel expose 30085:8000to try to forward this info. Doing this I get the output
INFO Exposed service's cluster ip is: 10.101.77.99 .INFO waiting for deployment to be ready ..... INFO port forwarding to https://192.168.49.2:8443/api/v1/namespaces/default/pods/thisisatest-59d5584c84-b5qrc/portforward INFO Waiting for port forward to finish INFO 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:30085on local host 8000 but not the correct response.
I have also attempted to run a tcp server with the https://webapp.io/blog/container-tcp-tunnel/
nc 127.0.0.1 8000 | kubectl exec -i tcpserver 127.0.0.1 30085 catBut am having poor results as well. Am I using these services incorrectly? Or is there a better way to do this all together?
Expose SSH on the pod and use SSH to do the reverse port forward
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/