Last active
February 7, 2021 12:15
-
-
Save pavel-agarkov/95dfca9ae70fd2b20a17cc9cca13d8f0 to your computer and use it in GitHub Desktop.
Shell script to attach vsdbg to container running in kubernetes
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
#!/bin/bash | |
set -e | |
# echo "processing params" | |
while [ "$1" != "" ]; do | |
case $1 in | |
-n | --namespace) | |
NAMESPACE=$2 | |
shift 2 | |
;; | |
-s | --selector) | |
SELECTOR=$2 | |
shift 2 | |
;; | |
*) | |
PARAMS="$PARAMS$1 " | |
shift 1 | |
;; | |
esac | |
done | |
# echo "serching for pod in ${NAMESPACE:-default} namespace and with $SELECTOR" | |
POD=`kubectl get pods -n ${NAMESPACE:-default} --selector=$SELECTOR -o jsonpath='{.items[0].metadata.name}'`; | |
# echo "starting debugger on $POD"; | |
kubectl exec $POD -n ${NAMESPACE:-default} -i -- $PARAMS; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment