Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tuxfight3r/169867c001684411814e5f8456f4a6ed to your computer and use it in GitHub Desktop.
Save tuxfight3r/169867c001684411814e5f8456f4a6ed to your computer and use it in GitHub Desktop.
Java JMX inspection via visualvm or jconsole for a pod inside kubernetes
#to be able to view the java jmx internals of an application running in kubernetes as a pod
# set the below environment value in the pod definition
_JAVA_OPTIONS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=5000
-Dcom.sun.management.jmxremote.rmi.port=5000
-Djava.rmi.server.hostname=127.0.0.1"
#portforward
kubectl port-forward "your-app-pod" 5000
#inspect via jconsole/visualvm
jconsole localhost:5000
or visualvm -> jmx -> remotehost: localhost:5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment