Last active
November 29, 2022 09:40
-
-
Save jedvardsson/27ba72a402d0bea42d78e98f95594e92 to your computer and use it in GitHub Desktop.
How to setup a port-forward to any host reachable from kubernetes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to set up a port-forward to any host reachable from a kubernetes namespace. | |
# Start a jump-off-pod with `socat` installed in a new terminal (unless there is a pod with socat installed) | |
kubectl run -it --rm --restart=Never jump-off-pod --image=wbitt/network-multitool:alpine-extra -- bash | |
# local socat that forward local port over stdio to a socat in a kubernetes pod | |
socat TCP-LISTEN:${LOCAL_PORT},reuseaddr,fork 'EXEC:"kubectl exec -i jump-off-pod -- socat STDIO TCP-CONNECT:${REMOTE_HOST}:${REMOTE_PORT}"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment