Skip to content

Instantly share code, notes, and snippets.

@axeal
Created July 25, 2024 14:47
Show Gist options
  • Save axeal/cdefb6d5959fb91bca5797a6a02f7cb6 to your computer and use it in GitHub Desktop.
Save axeal/cdefb6d5959fb91bca5797a6a02f7cb6 to your computer and use it in GitHub Desktop.
TS=`date -u +"%Y-%m-%d_%H%M"`
pprofs=( goroutine heap threadcreate block mutex )
for pod in $(kubectl -n cattle-system get pods --no-headers -l app=rancher -o custom-columns=":.metadata.name"); do
echo "getting profile for $pod..."
for pp in ${pprofs[@]}; do
echo "--> generating $pp..."
kubectl -n cattle-system exec $pod -c rancher -- curl -s http://localhost:6060/debug/pprof/$pp -o $pp
done
echo "--> taring it up..."
kubectl -n cattle-system exec $pod -c rancher -- tar -czf debug-pprof.tar.gz $pprofs
kubectl -n cattle-system cp -c rancher $pod:debug-pprof.tar.gz $pod-debug-pprof-$TS.tar.gz
echo saved debug profile $pod-debug-pprof-$TS.tar.gz
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment