Skip to content

Instantly share code, notes, and snippets.

@chaoyangnz
Created October 23, 2019 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaoyangnz/1abff088aa1e7bc2eea32919b00dc0f8 to your computer and use it in GitHub Desktop.
Save chaoyangnz/1abff088aa1e7bc2eea32919b00dc0f8 to your computer and use it in GitHub Desktop.
  • Kubectl exec Pod
gcloud container clusters get-credentials dunlap-gke-private --region australia-southeast1 --project stuff-98118045375 && \
kubectl exec stuff-content-service-67b9779bcf-fqb6c --namespace devint -c stuff-content-service -it -- sh
  • In Pod, dump the heap
apt-get update
apt-get install wget
wget -L -O /usr/local/bin/jattach \
    https://github.com/apangin/jattach/releases/download/v1.5/jattach && \
    chmod +x /usr/local/bin/jattach
java_pid=$(pidof -s java) && \
jattach $java_pid dumpheap /root/dump.hprof
  • Copy from Pod to cloud shell
gcloud container clusters get-credentials dunlap-gke-private --region australia-southeast1 --project stuff-98118045375 && \
kubectl cp stuff-content-service-67b9779bcf-fqb6c:/root/dump.hprof /home/chao_yang/dump.hprof --namespace devint -c stuff-content-service 
  • Download to local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment