Background
In a standard deployment, the ack-onepilot component specifies the mount path for a Java agent by injecting the JAVA_TOOL_OPTIONS environment variable. However, you may need to customize the agent mount path for specific scenarios, such as the following:
Centralized configuration management
You can manage agent paths centrally using a Kubernetes ConfigMap to ensure configuration consistency across multiple environments.
Persistent storage requirements
Enterprise security policies or O&M requirements may require storing probe files in a custom persistent volume (PVC).
Version dependencies
Customizing the Java agent mount path requires the following component versions:
ack-onepilot: version 4.1.0 or later.
ARMS Java agent: version 4.2.2 or later. You can also control the Java agent version as needed.
Solution
The ack-onepilot component is shared by Microservice Engine (MSE) and Application Real-Time Monitoring Service (ARMS). Therefore, this procedure also applies to MSE service administration applications.
Add the
disableJavaToolOptionsInjectionannotation to Kubernetes workloads, such as deployments, that require a custom-mounted Java agent.After you add this annotation, the ack-onepilot component will not use the JAVA_TOOL_OPTIONS environment variable to automatically specify the agent mount path or other Java Virtual Machine (JVM) parameters.
Run the following command to view the YAML file of the target deployment.
kubectl get deployment YOUR_DEPLOYMENT_NAME -o yamlNoteIf you are unsure of the deployment name, you can run the following command to list all deployments. Find the target deployment in the results, and then view its YAML file.
kubectl get deployments --all-namespacesYou can edit the YAML file for the target stateless application (Deployment).
kubectl edit deployment YOUR_DEPLOYMENT_NAME -o yamlIn the YAML file, add the following content under `spec.template.metadata`.
labels: armsPilotAutoEnable: "on" armsPilotCreateAppName: "<span class="var-span" contenteditable="true" data-var="YOUR_DEPLOYMENT_NAME">YOUR_DEPLOYMENT_NAME"</span> # Replace YOUR_DEPLOYMENT_NAME with your application name. disableJavaToolOptionsInjection: "true" # To customize the Java agent mount path, set this to true.
Add the mount path for the ARMS Java agent to your application startup script or Java startup command.
The default mount path is
/home/admin/.opt/AliyunJavaAgent/aliyun-java-agent.jar. Replace this path with your custom path.java -javaagent:/home/admin/.opt/AliyunJavaAgent/aliyun-java-agent.jar ... ... -jar xxx.jarOther information, such as the reporting region and license key, is injected by ack-onepilot through environment variables.