Skip to content

Instantly share code, notes, and snippets.

@toksdotdev
Created December 10, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toksdotdev/1ded4d25c3365e7801eeb3371d7b4a0d to your computer and use it in GitHub Desktop.
Save toksdotdev/1ded4d25c3365e7801eeb3371d7b4a0d to your computer and use it in GitHub Desktop.
Port forward k8 pod to local machine
NAMESPACE=production
POD_LABEL=app=core-service
HOST_PORT=8080
APP_PORT=3333
kubectl port-forward --namespace $NAMESPACE \
$(
kubectl get pod \
--namespace $NAMESPACE \
--selector="$POD_LABEL" \
--output jsonpath='{.items[0].metadata.name}' \
) \
$HOST_PORT:$APP_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment