Skip to content

Instantly share code, notes, and snippets.

@moio
Created June 16, 2023 10:18
Show Gist options
  • Save moio/7f7cf60ff061e0e6c3579ae1228dfca3 to your computer and use it in GitHub Desktop.
Save moio/7f7cf60ff061e0e6c3579ae1228dfca3 to your computer and use it in GitHub Desktop.
Explore a Rancher pprof CPU profile

Explore a Rancher pprof CPU profile

Grab a kubeconfig file pointing to the Rancher upstream cluster, then copypaste:

export KUBECONFIG=/path/to/the/upstream_cluster.yaml

for pod in $(kubectl get pods -n cattle-system --no-headers -l app=rancher | cut -d ' ' -f1); do
  echo Collecting 30s worth of profile data for $pod...
  kubectl exec -n cattle-system $pod -- curl -s http://localhost:6060/debug/pprof/profile -o profile
  kubectl cp cattle-system/${pod}:profile ./${pod}-profile
  echo saved ${pod}-profile
done

echo Opening browser on ${pod}-profile...
go tool pprof -http=: ./${pod}-profile

Example: image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment