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