JVM in Kubernetes with Helm


This section demonstrates the use of the sidecar pattern to mount the OverOps agent into a Kubernetes Deployment using helm. This is based on the use of the OverOps Agent Sidecar Docker Image which is demonstrated by attaching to the OverOps Event Generator. The OverOps Event Generator is an example JVM application that will throw various types of exceptions creating events that will be displayed on the OverOps UI.


OverOps Event Generator

The OverOps Event Generator is a great tool to test out an OverOps Installation!

OverOps Helm Chart

The OverOps Event Generator Helm Chart which can deploy the Event Generator Docker Image using a K8s Deployment. Take a look at the Deployment.yaml

        - name: overops-agent-sidecar
          image: "{{ .Values.overops.agentSidecar.repository }}:{{ .Values.overops.agentSidecar.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.overops.agentSidecar.pullPolicy }}
          - name: overops-agent
            mountPath: /takipi

The above snippet shows the overops-agent-sidecar being used as an initContainer which includes a volumeMount that will be used by main container. This volume mount will contain the OverOps Agent and related files.

Now lets look at the main container section, in this case overops-event-generator

        - name: {{ .Chart.Name }}
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
            - name: TAKIPI_COLLECTOR_HOST
              value: {{ include "overops-event-generator.collectorEndpoint" . }}
            - name: TAKIPI_COLLECTOR_PORT
              value: {{ .Values.overops.collectorPort | quote }}
            - name: TAKIPI_APPLICATION_NAME
              value: {{ .Values.overops.applicationName | quote }}
            - name: TAKIPI_PROPERTIES_FILE
              value: "/opt/takipi/private/agent.properties"              
            - name: JAVA_TOOL_OPTIONS
              {{- if .Values.overops.agentSidecar.useDebug }}
              value: "-agentpath:/takipi/lib/libTakipiAgent.so"
              {{- else }}
              value: "-agentpath:/takipi/lib/libTakipiAgent.so=takipi.debug.logconsole"
              {{- end }}
            {{- end }}
            - name: overops-private
              mountPath: /opt/takipi/private
            - name: overops-agent
              mountPath: /takipi

In the above snippet of the deployment.yaml, we see various environments variables used to configure the OverOps Java micro-agent. These are described in detailed Java Agent Properties but include the collector connection information as well as the path to agent binary (as defined by the JAVA_TOOL_OPTIONS variable.) Finally, the agent.properties file is also can optionally be used to pass settings into the java micro-agent.

Besides the environment section, there is also the volumeMounts which includes two volume mounts:

  • overops-private /opt/takipi/private - mount containing the agent.properties file (Optional)
  • overops-agent /takipi - mount containing the micro-agent binary.

The overops-agent is the same mount that is populated from the init-container and is how the mirco-agent is mounted into the main application.


Agent Ranking

Make sure that the OverOps Micro-Agent is the last -agentlib or -agentpath argument in your argument list if you are using any other agents with your application in addition to OverOps.

Testing with the OverOps Event Generator

To demonstrate the use with helm, we can install the OverOps Event Generator with the agent sidecar enabled and connect it to a running collector.


  1. This procedure assumes a K8s cluster is already available and you have kubectl and helm clients installed.
  2. The K8s cluster has access to the OverOps Docker hub repository.
  3. The K8s cluster has a running collector that can be accessed by the target namespace.

Add the OverOps Helm Repository

The first step is to add and update the overops helm repository to ensure you have the latest helm charts.

helm repo add overops https://overops.github.io/helm-charts
helm repo update

Install the Event Generator with the Helm Chart

In order to connect to a collector you will need to know the collector service name, in this case overops-collector-overops which is running in the same namespace.

helm install -n=overops --set overops.collectorHost=collector-overops-collector --set overops.agentSidecar.enabled=true event-generator overops/overops-event-generator
# Sample output
NAME: event-generator
NAMESPACE: overops
STATUS: deployed
.  ____                  ____
  / __ \_   _____  _____/ __ \____  _____
 / / / / | / / _ \/ ___/ / / / __ \/ ___/
/ /_/ /| |/ /  __/ /  / /_/ / /_/ (__  )
\____/ |___/\___/_/   \____/ .___/____/
Check your Backend Server connected to collector: collector-overops-collector

To Scale the amount of event generators run the following command (Defaults 1):
kubectl scale -n overops deployment event-generator-overops-event-generator --replicas=2

To Stop event generators scale to zero run the following command:
kubectl scale -n overops deployment event-generator-overops-event-generator --replicas=0

The OverOps Event Generator is now deployed and should be connected to the collector!

We can also describe the pod to see the use of the agent-sidecar init-container:

kubectl -n overops describe pod event-generator-overops-event-generator-567444796d-p7plv
Init Containers:
    Image:          overops/agent-sidecar:latest
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 04 Nov 2021 15:47:34 -0400
      Finished:     Thu, 04 Nov 2021 15:47:34 -0400
    Ready:          True
    Restart Count:  0
    Environment:    <none>
      /takipi from overops-agent (rw)

Finally, you can check the OverOps UI and verify that the OverOps Event Generator is connected and sending events.




Keep up to date on our OverOps Collector Helm Chart and OverOps Event Generator Docker.



If you're running more than one JVM inside a container and you do not want OverOps to monitor all of them, you'll need to modify the command used to start your JVM.

Instead of setting the JAVA_TOOL_OPTIONS environment variable, start your JVM with
-agentpath:/takipi/lib/libTakipiAgent.so before the -jar and -cp arguments.



For best results, name your applications and deployments at the JVM level.
see Naming the Application, Server, Deployment for details.



Verify that the -Dtakipi.* JVM arguments are located before the -jar and -cp arguments.

The OverOps Micro-Agent is a native agent and is OS-specific. If using an:

  • Alpine Linux based image, use the Alpine Agent
  • Red Hat and Debian based images, use the Standard Agent.