• debug kube-apiserver cpu/mem usage
    1, we need to forward specific pod to your local env
    2, copy remote binary in pod to your local env (no need slash before )
    kubectl cp <pod_name>:<binary_path_in_pod> <local_binary_path>
    kubectl port-forward <pod_name> <local_port>:<container_port>
    go tool pprof -top  http://127.0.0.1:<local_port>/debug/pprof/heap --mem
    go tool pprof  http://127.0.0.1:<local_port>/debug/pprof/profile --cpu
    go tool pprof <local_binary_path> 'http://localhost:<local_port>/debug/pprof/profile'
    go-torch -u http://127.0.0.1:6060/ --suffix /debug/pprof/heap
    

    3, if for kube-apiserver, we need use proxy to do this

    kubectl proxy --port=6060
    
  • other commands
    go tool pprof -pdf ~GOPATH/src/go-your-code/binary-file cpuprofile > cpuprofile.pdf
    
  • refers
    pprof
    go tool pprof
    refer
    flamegraph