Skip to content

Instantly share code, notes, and snippets.

@blankenshipz
Last active October 8, 2021 20:37
Show Gist options
  • Save blankenshipz/a89be1f55c2b60ef5cd2c0e5db23c491 to your computer and use it in GitHub Desktop.
Save blankenshipz/a89be1f55c2b60ef5cd2c0e5db23c491 to your computer and use it in GitHub Desktop.
Update linkerd loglevel for a deployment
#!/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