Skip to content

Instantly share code, notes, and snippets.

@moio
Last active April 28, 2023 15:18
Show Gist options
  • Save moio/120861c3a8383122e63c105ab5f11585 to your computer and use it in GitHub Desktop.
Save moio/120861c3a8383122e63c105ab5f11585 to your computer and use it in GitHub Desktop.
Explore a fleet-agent pprof CPU profile

Explore a fleet-agent pprof CPU profile

Grab a kubeconfig file pointing to the fleet-agent downstream cluster, then copypaste:

export KUBECONFIG=/path/to/kubeconfig.yaml

# get pod name
if kubectl get ns | grep cattle-fleet-system; then
  export NAMESPACE=cattle-fleet-system
else
  export NAMESPACE=fleet-system
fi
export POD=$(kubectl --namespace ${NAMESPACE} get pod --selector='app=fleet-agent' --output jsonpath="{.items[0].metadata.name}")

# forward port 6060 from the fleet-agent pod to localhost
kubectl --namespace $NAMESPACE port-forward pod/$POD 6060:6060 &

# collect 30s worth of profiles and open a browser to analyze them
go tool pprof -http=: "http://localhost:6060/debug/pprof/profile?seconds=30"

Example:

Screenshot 2023-04-28 at 15.21.53.pngimage

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