Created
March 18, 2020 05:57
-
-
Save marcelaraujo/9dcc43dd8a53a44303fb382dd2d4d40b to your computer and use it in GitHub Desktop.
K8S Port Forward
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
| If you want to forward a non-k8s-managed port and have permission to stand up a new pod, you can run the alpine/socat image and port-forward to that: | |
| kubectl run --restart=Never --image=alpine/socat TEMP_POD_NAME -- -d -d tcp-listen:PORT,fork,reuseaddr tcp-connect:HOSTNAME:PORT | |
| kubectl wait --for=condition=Ready pod/TEMP_POD_NAME | |
| kubectl port-forward pod/TEMP_POD_NAME LOCAL_PORT:PORT | |
| Don't forget to bring the pod down once you're done. | |
| kubectl delete pod/TEMP_POD_NAME --grace-period 1 --wait=false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment