All Products
Search
Document Center

Application Real-Time Monitoring Service:Automatically install the agent in a general-purpose Kubernetes environment

Last Updated:Jul 15, 2026

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.

Note

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.

  1. Register your Kubernetes cluster with ACK One. For more information, see Create a registered cluster in ACK One.

  2. 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

Important

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.

  1. Run the following wget command 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'
  2. Run the following command to extract the ack-onepilot installation package.

    tar xvf ack-onepilot-5.2.1.tgz                 
  3. 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>.

    • accessKey and accessKeySecret: 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.

    Note

    If 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"
  4. 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

  1. Run the following command to view the YAML file of the target stateless (Deployment) application.

    kubectl get deployment {deployment-name} -o yaml                            
    Note

    If 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                
  2. Run the following command to edit the YAML file of the target stateless (Deployment) application.

    kubectl edit deployment {deployment-name} -o yaml                        
  3. 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: java
    Note

    For 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:

    Complete sample YAML for a new deployment

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: arms-springboot-demo
      labels:
        app: arms-springboot-demo
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: arms-springboot-demo
      template:
        metadata:
          labels:
            app: arms-springboot-demo
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo"
        spec:
          containers:
            - resources:
                limits:
                  cpu: 0.5
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-springboot-demo:v0.1
              imagePullPolicy: Always
              name: arms-springboot-demo
              env:
                - name: MYSQL_SERVICE_HOST
                  value: "arms-demo-mysql"
                - name: MYSQL_SERVICE_PORT
                  value: "3306"
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: arms-demo-mysql
      labels:
        app: mysql
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
            - resources:
                limits:
                  cpu: 0.5
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-demo-mysql:v0.1
              name: mysql
              ports:
                - containerPort: 3306
                  name: mysql
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        name: mysql
      name: arms-demo-mysql
    spec:
      ports:
        # the port that this service should serve on
        - name: arms-mysql-svc
          port: 3306
          targetPort: 3306
      # label keys and values that must match in order to receive traffic for this service
      selector:
        app: mysql
    ---
  4. After you save the configuration, the application automatically restarts to apply the changes.

    After 2 to 5 minutes, if your application appears on the Application Monitoring > Application List page on the ARMS console and begins reporting data, the connection is successful.