Prerequisites
1. A persistent volume (with a capacity of 100mb).
2. The persistent volume mounted on all deployment pods (via persistent volume claim).
3. The Applications Manager APM Insight Java agent zip file was downloaded, moved, and extracted to this volume.
Note: You can download the agent zip file from this link. 4. Add the Applications Manager license key (copied from our web client) to the apminsight.conf file, if you wish to keep it as a secret, skip this step.
5. If there is any proxy connection, provide the proxy details in the apminsight.conf file
Instructions
1. If you have provided the Applications Manager license key in the apminsight.conf file, you can skip this step. Otherwise, include it in the application secrets file.
Example:
kubectl create secret generic app-secret --from-literal=s247licensekey='AppManager_license_key' -n petclinic
Replace app-secret, AppManager_license_key, and namespace petclinic with the appropriate values.
2. You must include the following two environment variables in the application deployment YAML file as shown.If the license key is provided in the apminsight.conf file, ignore this step.
a. Name: S247_LICENSE_KEY
Value: s247licensekey from the secret added in step 1.
b. Name: JAVA_TOOL_OPTIONS
Value: "-javaagent:[mount/path]/apminsight-javaagent.jar -Dapminsight.application.name=[DesiredMonitorName] -apminsight.log.dir=/home/apm"
In this step, we configure the arguments that the application (Java process) will use during startup, and the agent to report data to the specified monitor name and agent logs to be written to the path /home/apm.
Example
env:
- name: S247_LICENSE_KEY
valueFrom:
secretKeyRef:
name: app-secret
key: s247licensekey
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:[mount/path]/apminsight-javaagent.jar -Dapminsight.application.name=[DesiredMonitorName] -apminsight.log.dir=/home/apm"
Note:
- If the agent jar file (apminsight-javaagent.jar) is not available during application startup, the pod creation will fail.
- The agent update must be done manually with this method.
Sample Kubernetes Deployment YAML file
apiVersion: v1
kind: Namespace
metadata:
name: petclinic
---
apiVersion: v1
kind: PersistentVolume
metadata:
namespace: petclinic
name: agent-storage
spec:
capacity:
storage: 50Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/opt/apm"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: petclinic
name: agent-pvc
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: petclinic
name: petclinic-deployment
spec:
replicas: 2
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
spec:
volumes:
- name: agent
persistentVolumeClaim:
claimName: agent-pvc
containers:
- name: petclinic
image: petclinic:2.5
ports:
- containerPort: 8080
volumeMounts:
- name: agent
mountPath: /opt/apm/
env:
- name: S247_LICENSE_KEY
valueFrom:
secretKeyRef:
name: app-secrets
key: s247license
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/opt/apm/apminsight-javaagent.jar -Dapminsight.application.name=Petclinic -Dapminsight.log.dir=/home/apm"