Last active
October 8, 2021 20:37
-
-
Save blankenshipz/a89be1f55c2b60ef5cd2c0e5db23c491 to your computer and use it in GitHub Desktop.
Update linkerd loglevel for a deployment
This file contains 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 | |
# Usage: ./linkerd-set-log-level.sh app-name level | |
APP=$1 | |
LEVEL=$2 | |
declare -a PODS=($( | |
kubectl \ | |
get \ | |
pods \ | |
--selector=app=$APP \ | |
-o json | \ | |
jq -r '.items[].metadata.name' | |
)) | |
for pod in "${PODS[@]}" | |
do | |
echo "Updating linkerd-proxy log level to *$LEVEL* for $pod..." | |
# Background port-fowarding | |
kubectl port-forward $pod linkerd-admin &> /dev/null & | |
# Give a second for the port-forward to be setup | |
sleep 1 | |
# Submit the request to change the level | |
curl --data "linkerd=$LEVEL" -X PUT localhost:4191/proxy-log-level | |
# Kill the port-forward and wait for it to exit; supressing the termination | |
kill $! | |
wait $! 2>/dev/null | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment