Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moio/20c203baac38d6d11a81a7b5588e9443 to your computer and use it in GitHub Desktop.
Save moio/20c203baac38d6d11a81a7b5588e9443 to your computer and use it in GitHub Desktop.
Collect Rancher's cattle-cluster-agent heap profile every 2 minutes

Run the following commands:

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

while true; do
    for pod in $(kubectl get pods -n cattle-system --no-headers -l app=cattle-cluster-agent | cut -d ' ' -f1); do
      echo getting heap for $pod
      kubectl exec -n cattle-system $pod -- curl -s http://localhost:6060/debug/pprof/heap -o heap
      kubectl cp cattle-system/${pod}:heap ./${pod}-heap-$(date +'%Y-%m-%dT%H_%M_%S')
    done
    sleep 120
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment