Created
December 9, 2022 09:58
-
-
Save mantono/c2a18ad08ba0fcf07ee96c73abd0aa0d to your computer and use it in GitHub Desktop.
Create a proxy from your local host to kubernetes pod
This file contains 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
#!/bin/sh | |
# 1 = namespace | |
# 2 = podname | |
# 3 = local port | |
# 4 = port in pod | |
POD=$(kubectl get pods --namespace $1|grep $2|head -n 1|cut -d " " -f 1 ) | |
echo "Found pod $POD" | |
echo "Will forward localhost:$3 to pod on port $4" | |
sleep 1 | |
kubectl --namespace $1 port-forward $POD $3:$4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment