Connect Java applications in a general-purpose Kubernetes environment to ARMS Application Monitoring to monitor application topology, API calls, slow and abnormal transactions, and SQL queries.
If your Kubernetes cluster runs on Container Service for Kubernetes (ACK), this topic does not apply. To connect an ACK cluster to ARMS, see Install the Java agent for ACK and ACS by using the ack-onepilot component.
Prerequisites
-
Your Kubernetes cluster runs version 1.18 or later.
-
If your Kubernetes cluster is not deployed on Alibaba Cloud, make sure that the cluster can access the public internet or is connected to an Alibaba Cloud VPC through Cloud Enterprise Network (CEN) or other methods.
Your JDK version is supported by Application Monitoring
The JVM maximum heap memory (
-Xmx) is at least 256 MB
Method 1: Connect with a registered cluster in ACK One
Benefits of using a registered cluster in ACK One:
-
More efficient O&M support.
-
Access to more cluster extension capabilities of Container Service for Kubernetes (ACK), including monitoring, logging, backup and restore, security, and elastic cloud resources. For more information, see Overview of registered clusters.
-
Register your Kubernetes cluster with ACK One. For more information, see Create a registered cluster in ACK One.
-
Install the ack-onepilot component for the registered cluster. For more information, see Connect a registered cluster to ARMS Application Monitoring.
Method 2: Connect directly to ARMS
This method does not use a registered cluster. After you connect your application, container-related information such as CPU, memory, disk, and network usage cannot be correlated or displayed. As a result, the Application Instances page displays only the container environment data collected by ARMS. You also cannot view container data from Prometheus agents by connecting to Managed Service for Prometheus. For more information, see Java application instance monitoring.
Step 1: Install Helm 3
Step 2: Install the agent
ARMS Application Monitoring supports only stateless (Deployment) and stateful (StatefulSet) applications. The connection method is the same for both types. The following example uses a stateless (Deployment) application.
-
Run the following
wgetcommand to download the ack-onepilot installation package.wget 'https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ack-onepilot-5.2.1.tgz' -
Run the following command to extract the ack-onepilot installation package.
tar xvf ack-onepilot-5.2.1.tgz -
Modify the following parameters in the values.yaml file as required, and then save the file.
registry: registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ cluster_id: __ACK_CLUSTER_ID__ accessKey: __ACCESSKEY__ accessKeySecret: __ACCESSKEY_SECRET__ uid: "__ACK_UID__" region_id: __ACK_REGION_ID__-
registry: The ack-onepilot image registry. -
cluster_id: A custom Kubernetes cluster ID. This ID must be unique within the cluster. The recommended format is<uid>-<clusterid>. -
accessKeyandaccessKeySecret: The AccessKey ID and AccessKey Secret of your Alibaba Cloud account. For more information about how to obtain them, see Create an AccessKey pair.Important-
Make sure that the Alibaba Cloud account has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions.
-
If you are using a RAM user, make sure that the RAM user also has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions. For instructions, see Grant permissions to a RAM user.
-
For security, you can use a Kubernetes Secret to manage your AccessKey pair. For more information, see Method 2: Use a Kubernetes Secret to import an AccessKey pair.
-
-
uid: The ID of your Alibaba Cloud account. To find the ID, hover over your profile picture in the upper-right corner of the Alibaba Cloud console. -
region_id: The Alibaba Cloud region ID. For a list of regions where Application Monitoring is available, see Supported regions.
NoteIf the target cluster is an edge cluster, add a nodeSelector annotation to schedule the ack-onepilot component on cloud nodes. This ensures that ack-onepilot functions correctly.
kind: Deployment apiVersion: apps/v1 metadata: name: xxx namespace: xxx spec: template: spec: nodeSelector: # Replace with the actual node selector. alibabacloud.com/is-edge-worker: "false" -
-
Run the following command to install ack-onepilot.
Run this command from outside the ack-onepilot installation package directory.
helm3 upgrade --install ack-onepilot ack-onepilot --namespace ack-onepilot --create-namespace
Step 3: Modify the application YAML file
-
Run the following command to view the YAML file of the target stateless (Deployment) application.
kubectl get deployment {deployment-name} -o yamlNoteIf you do not know the
{deployment-name}, run the following command to view all stateless (Deployment) applications. Find the target application in the output, and then view its YAML file.kubectl get deployments --all-namespaces -
Run the following command to edit the YAML file of the target stateless (Deployment) application.
kubectl edit deployment {deployment-name} -o yaml -
Add the following content under the spec.template.metadata section in the YAML file.
labels: armsPilotAutoEnable: "on" armsPilotCreateAppName: "<your-deployment-name>" # Replace <your-deployment-name> with your application name. aliyun.com/app-language: javaNoteFor more information about application security, see What is application security?.
For more information about application security billing, see Billing overview.
The following sample YAML file creates and connects a new stateless (Deployment) application to ARMS:
-
After you save the configuration, the application automatically restarts to apply the changes.
After 2 to 5 minutes, if your application appears on the page on the ARMS console and begins reporting data, the connection is successful.