Skip to content

Instantly share code, notes, and snippets.

@mikejoh
Created February 24, 2021 20:15
Show Gist options
  • Save mikejoh/7363495c89675c854fec9cab0ba8c877 to your computer and use it in GitHub Desktop.
Save mikejoh/7363495c89675c854fec9cab0ba8c877 to your computer and use it in GitHub Desktop.
CPU profiling calico-node (felix) v3.16.5 running in a Kubernetes Pod using pprof

CPU profiling calico-node (felix) v3.16.5 running in a Kubernetes Pod using pprof

Create a pprof profile:

kubectl exec -it -n kube-system calico-node-abcd -c calico-node -- sv -w 60 2 felix

List all files in /tmp/:

kubectl exec -it -n kube-system calico-node-abcd -c calico-node -- ls -l /tmp
-rw-r--r-- 1 root root 10336 Feb 24 20:01 felix-cpu-2021-02-24-20:01:37.pprof

Copy pprof file from container:

kubectl exec -n kube-system calico-node-abcd -c calico-node -- cat /tmp/felix-cpu-2021-02-24-20:01:37.pprof > /tmp/felix-cpu-2021-02-24-20:01:37.pprof

Copy the calico-node binary of a Docker image running version v3.16.5:

docker run --rm quay.io/calico/node:v3.16.5 cat /bin/calico-node > /tmp/calico-node

Run go tool pprof and generate a PDF with CPU profile visualizations:

go tool pprof -pdf /tmp/calico-node /tmp/felix-cpu-2021-02-24-20:01:37.pprof

Run go tool pprof serving the CPU profile visualizations from a local web server:

go tool pprof -http localhost:8080 /tmp/calico-node /tmp/felix-cpu-2021-02-24-20:01:37.pprof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment