---
title: "Java APM with Kubernetes"
slug: "java-apm-with-kubernetes"
description: "Install Java APM Profiler for your Kubernetes-based Java app. Follow our guide for Dockerfile and pod configuration. Monitor results in the Retrace dashboard."
updated: 2020-05-05T22:19:57Z
published: 2020-05-05T22:19:57Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java APM with Kubernetes

This document details how to install the **Java APM Profiler** in your **Java** application running on **Kubernetes**.

## Prerequisite

Follow the **[Retrace Kubernetes Install](/docs/retrace-kubernetes-install)** Guide.

## Java Kubernetes Setup

#### Dockerfile Configuration

Adjust your **Dockerfile** to include the Java Profiler.

```
RUN mkdir -p /stackify-java-apm && \
    cd /stackify-java-apm && \
    wget https://download.stackify.com/stackify-java-apm/stackify-java-apm-latest.tar.gz; tar -zxvf  stackify-java-apm-latest.tar.gz; rm stackify-java-apm-latest.tar.gz && \
    ./install.sh
```

#### Enabling the Java Agent

Follow **[Enable the Stackify Java Profiler](/docs/java-apm-with-linux#enable-the-stackify-java-profiler)** instructions based on the application server being used.

**Note:** Adjust the Java Profiler path to: `/stackify-java-apm/stackify-java-apm.jar`.

#### Pod Configuration

Application containers are required to have the stackify volume mount configured in [Retrace Kubernetes Install](/docs/retrace-kubernetes-install).

Example Application Pod YAML:

```
apiVersion: v1
kind: ReplicationController
metadata:
  name: pod-name
spec:
  replicas: 1
  selector:
    app: app-name
  template:
    metadata:
      name: template-name
      labels:
        app: app-name
    spec:
      containers:
      - name: container-name
        image: application-image
        env:
          - name: STACKIFY_APPLICATION_NAME
            value: "My Java Application"
          - name: STACKIFY_ENVIRONMENT_NAME
            value: "Production"
        volumeMounts:
          - mountPath: /usr/local/stackify
            name: stackify
      volumes:
        - name: stackify
          hostPath: 
            path: /var/stackify
            type: DirectoryOrCreate
```

Customize the `STACKIFY_APPLICATION_NAME` and `STACKIFY_ENVIRONMENT_NAME` values.

## Verify

Make application requests, you can then verify results in the Retrace dashboard.
