Skip to content

Instantly share code, notes, and snippets.

@christian-posta
Created February 13, 2020 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christian-posta/02cf0009f9262c2ba3ae746d0e9f30b4 to your computer and use it in GitHub Desktop.
Save christian-posta/02cf0009f9262c2ba3ae746d0e9f30b4 to your computer and use it in GitHub Desktop.
Script to Debug Gloo with Squash
GLOO=${1:-gloo}
POD=$(kubectl get po -n gloo-system | grep $GLOO | awk '{ print $1 }' | head -n 1)
echo "gloo pod to debug '$POD'"
PF_CMD=$(squashctl --debugger dlv --namespace gloo-system --machine --pod $POD)
echo "PF CMD: $PF_CMD"
K_CMD=$(echo "$PF_CMD" | jq .PortForwardCmd | sed s/:/2345:/)
K_CMD="${K_CMD%\"}"
K_CMD="${K_CMD#\"}"
echo "running command $K_CMD"
SQUASH_POD=$(echo $K_CMD | awk '{ print $3}')
echo "Squash pod $SQUASH_POD"
function cleanup {
echo "Deleting squash pod $SQUASH_POD"
kubectl delete pod -n squash-debugger $SQUASH_POD
}
trap cleanup EXIT
bash -c "$K_CMD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment