Skip to content

Instantly share code, notes, and snippets.

@mantono
Created December 9, 2022 09:58
Show Gist options
  • Save mantono/c2a18ad08ba0fcf07ee96c73abd0aa0d to your computer and use it in GitHub Desktop.
Save mantono/c2a18ad08ba0fcf07ee96c73abd0aa0d to your computer and use it in GitHub Desktop.
Create a proxy from your local host to kubernetes pod
#!/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