skarsaune / jmc-cloud-extensions

Other
6 stars 2 forks source link

Jolokia plugins for Java Mission Control

Objective

Allow Java Mission Control to connect to Jolokia enabled JVMs over the network or in kubernetes

Installing

  1. If you have not already, download eclipse IDE
  2. Install Java Mission Control 8.1 or newer from update site : https://github.com/AdoptOpenJDK/openjdk-jmc-overrides/releases/download/8.1.0/org.openjdk.jmc.updatesite.ide-8.1.0.zip
    • Download
    • Help \ Install New Software ... \ Add ... \ Archive ... \ Select the downloaded file
    • Select Java Mission Control and any other features you want
  3. Add Jolokia JMC plugins from the plugin site: https://skarsaune.github.io/jolokia-jmc-update-site
    • If Jolokia and Kubernetes features do not show up, deselect "Group items by category"
    • Install Jolokia and Kubernetes plugins

video of installation

Connecting to JVMs

To connect directly to JVMs with Jolokia over a regular network connection:

To use Jolokia Discovery to detect JVMs running with Jolokia

Under JDK Mission Control \ JVM Browser \ Jolokia , check "Discover Jolokia Agents". A process will run in the background and update the list of JVMs every 30 seconds

Settings to discover Jolokia!

To scan kubernetes for JVMs

Under JDK Mission Control \ JVM Browser \ Kubernetes , check "Scan for kubernetes pods with Jolokia support". A process will run in the background and update the list of JVMs every 30 seconds

Settings to scan kubernetes!

Any pods that are successfully probed will show up in the JVM Browser hierarchy under kubernetes/context/namespace : Pods in JVM Browser!

Example snippet of a helm chart of a deployment that declares properties suitable for scanning from JMC:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: petclinic
  namespace: jfr
  labels:
    jolokia: 'true'
    k8s-app: petclinic
  annotations:
    deployment.kubernetes.io/revision: '3'
spec:
  replicas: 2
  selector:
    matchLabels:
      k8s-app: petclinic
  template:
    metadata:
      name: petclinic
      annotations:
        jolokiaPath: 'jolokia/'
        jolokiaPort: '8778'
      labels:
        k8s-app: petclinic
        jolokia: 'true'
    spec:
      volumes:
      - name: jolokia-properties
        secret:
          secretName: jolokia-properties
      containers:
        - name: petclinic
          image: kantega.azurecr.io/petclinic:latest
          ports:
          - name: http
            containerPort: 8080
            protocol: TCP
          - name: jolokia
            containerPort: 8778
            protocol: TCP
          volumeMounts:
          - name: jolokia-properties
            readOnly: true
            mountPath: "/etc/jolokia"
          env:
            - name: JAVA_TOOL_OPTIONS
              value: "-javaagent:/jolokia-jvm-agent.jar=config=/etc/jolokia/jolokia.properties "

To develop or troubleshoot the Jolokia or Kubernetes plugins

  1. Clone jmc git clone git@github.com:openjdk/jmc.git
  2. Follow instructions to build
  3. Open the projects in an Eclipse workspace
  4. Clone this repo or a fork of it
  5. Run mvn dependency:copy-dependencies in subfolders org.openjdk.jmc.jolokia and org.openjdk.jmc.kubernetes
  6. Open the projects in the same workspace as where you have the jmc projects
  7. Debug JMC or Eclipse with JMC with one of the Jolokia or Kubernetes launchers
  8. Feel free to register issues with suggestions or problems in this repo

Visual VM plugin

  1. Download plugin https://skarsaune.github.io/jolokia-jmc-update-site/visualvm/org-jolokia-jmx-plugin.nbm
  2. Add downloaded plugin and choose install image