Edit Dockerfile to enable JMX server and change the hostname with the IP where the container will run:
FROM openjdk:8-jre-alpine
ADD ./target/app.jar app.jar
EXPOSE 8080
ENTRYPOINT java -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.1.2 -jar app.jar
Edit the Helm Chart service.yaml file adding the following code:
{{- if .Values.service.apply -}}
apiVersion: v1
kind: Service
...
spec:
type: {{ .Values.service.type }}
ports:
- port: 9090
targetPort: profiler
protocol: TCP
name: profiler
...
In the Helm Chart values.yaml file change the service to LoadBalancer:
...
service:
apply: true
type: LoadBalancer
port: 80
...
In the Helm Chart deployment.yaml file add a containerPort:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
...
spec:
...
template:
...
spec:
...
containers:
- name: {{ .Chart.Name }}
...
ports:
- name: profiler
containerPort: 9090
protocol: TCP
Download and install the tool Visual VM.
After open the tool, right click Applications > Remote > Add Remote Host... In the host name put the same IP of Dockerfile, in this case 192.168.1.2 then click Ok.
Now right click in the IP bellow Remote, Add JMX Connection and put the same port of Dockerfile, in this case 9090.
The configuration is done, now double click the JMX connection you've created and the JVM statistics should appear.
doesn't work - when tried with external kubernetes cluster