How to Expose Jmx in Kubernetes?

Introduction

Let’s start

Add JVM options to your application

-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

Forward the JMX port (5000) to your local PC via kubectl

C:\Tools\cmder
λ kubectl port-forward "your-app-pod" 5000

Open connection with jconsole to your local port 5000

C:\Tools\cmder
λ jconsole 127.0.0.1:5000
Source: https://giphy.com/gifs/animation-spongebob-rubber-hose-moFzjcoCTbawHPbvLz

DevOps Consultant. I’m strongly focused on automation, security, and reliability.