Skip to content

Instantly share code, notes, and snippets.

@joosangkim
Last active April 25, 2022 04:29
Show Gist options
  • Save joosangkim/87cddf1583e6bbe692168fe0015fd99b to your computer and use it in GitHub Desktop.
Save joosangkim/87cddf1583e6bbe692168fe0015fd99b to your computer and use it in GitHub Desktop.
create istio memory profile
export POD=$1
export NS=$2
export PROFILER="heap" # Can also be "heap", for a heap profile
export DIR=$(date +"%Y%m%d%H%M")_$POD
mkdir -p $DIR/envoy/lib
kubectl exec -n "$NS" "$POD" -c istio-proxy -- curl -X POST -s "http://localhost:15000/${PROFILER}profiler?enable=y"
sleep 15
kubectl exec -n "$NS" "$POD" -c istio-proxy -- curl -X POST -s "http://localhost:15000/${PROFILER}profiler?enable=n"
kubectl cp -n "$NS" "$POD":/var/lib/istio/data $DIR/envoy -c istio-proxy
kubectl cp -n "$NS" "$POD":/lib/x86_64-linux-gnu $DIR/envoy/lib -c istio-proxy
kubectl cp -n "$NS" "$POD":/usr/local/bin/envoy $DIR/envoy/lib/envoy -c istio-proxy
## It will create $(date +"%Y%m%d%H%M")_PODNAME format directory
## Move to the directory and then exec PPROF_BINARY_PATH=envoy/lib pprof -http=localhost:8000 envoy/lib/envoy envoy/envoy.prof.000X.heap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment