how to connect visualvm with the application running in kubernetes pod?

492 views Asked by At

I have an application running as a pod in a Kubernetes cluster, specifically on an Amazon EKS cluster. I want to monitor the heap size of this application using VisualVM. How can I connect VisualVM to the application in my Kubernetes cluster, and what configurations do I need to make? Do I need to modify the deployment YAML file, or can I make changes to the Dockerfile for this purpose?

expecting answers to solve my issue!

2

There are 2 answers

16
Harsh Manvar On

Not sure where your VisualVM running. If it's running on the same Kubernetes cluster you can use the service name to connect with Application.

If it's somewhere out and you have to expose your service to the internet and connect to VisualVM, you can use service type LoadBalancer or Use ingress.

You also might like to whitelist IP so that over the internet only VisualVM can connect to your service.

If your VisualVM running on AWS cloud VM(windows/linux) you can create internal LB service type on Kubernetes and expose your service and use that IP.

Update service.yaml

apiVersion: v1
kind: Service
metadata:
  name: mendix-app-service-lb
  labels:
    app: mendix-k8s
spec:
  ports:
  - name: http
    port: 8080
    protocol: TCP
  - name: jmx
    port: 7845
    protocol: TCP
  selector:
    app: mendix-k8s
  type: LoadBalancer
  loadBalancerSourceRanges:
  - 160.2X1.2X4.1/32 #Add your IP here to the whitelist so only you can connect
2
Mr_Thorynque On

You can use port-forward direct on the pod and un visualVM in localhost:31743. Use kubcet get pod to know fullname of the pod.

kubectl port-forward mendix-app-XXX  31743:31743