Kubernetes: How to take a thread dump of an app

6/19/2020

I am using openjdk:8-jre-alpine3.9 docker image to run my java app in Kubernetes. I wanted to have thread dump functionality for this running app. The java image doesn't seem to have that jstack or jmeter tool within it.

Any idea how can I achieve thread dump?

-- KaustubhN
java
kubernetes
thread-dump

1 Answer

6/19/2020

Assuming the java process is PID 1 in the container, you can send it a SIGQUIT and it will emit a thread dump to stdout(?)

kubectl exec $POD_NAME -- kill -QUIT 1

Apologies for the redhat link, I couldn't immediately find the authoritative source for that on oracle.com

-- mdaniel
Source: StackOverflow