Is it possible to configure kubectl port-forward to not exit on connection refused?

65 views Asked by At

I am attempting to use the socat gender change trick with the following commands, to allow code inside the pod to access google.com (as an example).

# Terminal 1
kubectl port-forward $POD 5432:5432

# Terminal 2
kubectl exec $POD -it -- bash
socat TCP-LISTEN:5431,reuseaddr,fork TCP-LISTEN:5432,reuseaddr

# Terminal 3
socat TCP:localhost:5432,forever,interval=1,fork TCP:google.com:443

Unfortunately, as soon as I start the command in Terminal 3, I get the error address localhost: no suitable address found followed by lost connection to pod in Terminal 1.

Is it possible to configure kubectl port-forward to NOT exit after failing to make a connection?

I've looked at man kubectl-port-forward but did not see any obvious flags for this.

0

There are 0 answers