After you install the Application Real-Time Monitoring Service (ARMS) agent for a Java application that is deployed in Container Service for Kubernetes (ACK), ARMS starts to monitor the Java application. You can view the monitoring data of application topology, API requests, abnormal transactions, and slow transactions. This topic describes how to install the ARMS agent for a Java application that is deployed in ACK.

Prerequisites

Step 1: Install the ARMS agent

Install the ARMS agent that is named ack-arms-pilot.

  1. Log on to the ACK console.
  2. In the left-side navigation pane, choose Marketplace > App Catalog. On the Alibaba Cloud Apps tab, click ack-arms-pilot.
  3. In the Deploy section of the View Details page of ack-arms-pilot, select the cluster where the application to be monitored is deployed and click Create.

Step 2: Enable ARMS for a Java application

To enable ARMS when you create an application, perform the following steps.
Notice

When you use the ack-arms-pilot agent to create an ARMS instance, ARMS performs password-free authorization if the image version of ack-arms-pilot is V1.30 or later and ARMS Addon Token is enabled for the ACK cluster. Otherwise, you must manually grant access permissions on ARMS resources to ACK.

Only managed Kubernetes clusters and serverless Kubernetes (ASK) clusters support ARMS Addon Token. Therefore, you need to manually grant access permissions to clusters of other types. ARMS Addon Token may not be enabled for some managed Kubernetes clusters and serverless Kubernetes(ASK) clusters. We recommend that you check whether the ARMS Addon Token are enabled for managed Kubernetes clusters and ASK clusters. If ARMS Addon Token is not enabled, you must manually enable it.

For information about how to view the arms-pilot image version and ARMS Addon Token, see How do I view the image version of ack-arms-pilot? and How do I check whether a cluster has ARMS Addon Token enabled? .

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters. On the Clusters page, click Applications in the Actions column of the cluster where your application is deployed.
  2. On the Deployments page, click Create from YAML in the upper-right corner.
  3. On the page that appears, select a template from the Sample Template drop-down list, and add the following annotations to the spec > template > metadata section in the Template code editor.
    Note Replace <your-deployment-name> with the name of your application.
    annotations:
      armsPilotAutoEnable: "on"
      armsPilotCreateAppName: "<your-deployment-name>"                                
    YAML Example

    The following YAML template shows how to create a stateless application and enable ARMS for the application:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: arms-demo
    ---
    apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-springboot-demo
      namespace: arms-demo
      labels:
        app: arms-springboot-demo
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: arms-springboot-demo
      template:
        metadata:
          annotations:
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo"
          labels:
            app: arms-springboot-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: SELF_INVOKE_SWITCH
                  value: "true"
                - name: COMPONENT_HOST
                  value: "arms-demo-component"
                - name: COMPONENT_PORT
                  value: "6666"
                - name: MYSQL_SERVICE_HOST
                  value: "arms-demo-mysql"
                - name: MYSQL_SERVICE_PORT
                  value: "3306"
    ---
    apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-springboot-demo-subcomponent
      namespace: arms-demo
      labels:
        app: arms-springboot-demo-subcomponent
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: arms-springboot-demo-subcomponent
      template:
        metadata:
          annotations:
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo-subcomponent"
          labels:
            app: arms-springboot-demo-subcomponent
        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-subcomponent
              env:
                - name: SELF_INVOKE_SWITCH
                  value: "false"
                - name: MYSQL_SERVICE_HOST
                  value: "arms-demo-mysql"
                - name: MYSQL_SERVICE_PORT
                  value: "3306"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        name: arms-demo-component
      name: arms-demo-component
      namespace: arms-demo
    spec:
      ports:
        # the port that this service should serve on
        - name: arms-demo-component-svc
          port: 6666
          targetPort: 8888
      # label keys and values that must match in order to receive traffic for this service
      selector:
        app: arms-springboot-demo-subcomponent
    ---
    apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-demo-mysql
      namespace: arms-demo
      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
      namespace: arms-demo
    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
    ---
    

Execution result

On the Deployments tab, find the application and check whether the ARMS Console button appears in the Actions column.

ARMS Console Button

Uninstall the ARMS agent

  1. Log on to the Alibaba Cloud Container Service for Kubernetes console.
  2. In the left-side navigation pane, click Clusters. On the Clusters page, find the cluster that contains the Java application from which you want to uninstall the ARMS agent and click Applications in the Actions column.
  3. In the left-side navigation pane, choose Applications > Helm.
  4. On the Helm tab, find the release named arms-pilot of the ARMS agent, and click Delete in the Actions column.
  5. In the Delete message, click OK.
  6. Restart your business pod.

FAQ

How do I change the name of an application?

To change the name of an application, you must modify the armsPilotCreateAppName parameter in the Deployment application. For more information, see FAQ about application monitoring.

How do I view the image version of ack-arms-pilot?

  1. Log on to the ACK console.
  2. On the Clusters page, find the instance that you want to manage and click the instance ID.
  3. In the left-side navigation pane of the details page, choose Workloads > Deployments.
  4. In the upper part of the page, select arms-pilot from the Namespace drop-down list to view the image version of the arms-pilot-ack-arms-pilot instance. Image version of ack-arms-pilot

How do I check whether ARMS Addon Token is enabled for a cluster?

  1. Log on to the ACK console.
  2. On the Clusters page, find the instance that you want to manage and click the instance ID.
  3. In the left-side navigation pane, choose Configurations > Secrets.
  4. In the upper part of the page, select kube-system from the Namespace drop-down list to check whether addon.arms.token is enabled. ARMS Addon Token

Why does ARMS Agent fail to be installed?

Probable cause: The image version of the arms-pilot is earlier than V1.30 or ARMS Addon Token cluster does not exist.
Note For more information about how to view the ack-arms-pilot image version and ARMS Addon Token, see How do I view the ack-arms-pilot image version? and How do I check whether ARMS Addon Token is enabled for a cluster?.

Solution: Grant ACK the permissions to access ARMS.

How do I report data across regions?

  1. In the Deployment application that is deployed in the arms-pilot namespace of the ACK cluster, add the ARMS_REPORT_REGION environment variable. The value must be an ID of the region where ARMS is available. For example, you can set the value to cn-hangzhou or cn-beijing.
  2. Restart the existing application or deploy a new application to report data across regions.
    Note After the environment variable is added, all applications that are deployed in the cluster report data to the specified region.