Created
February 13, 2020 16:22
-
-
Save christian-posta/02cf0009f9262c2ba3ae746d0e9f30b4 to your computer and use it in GitHub Desktop.
Script to Debug Gloo with Squash
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
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