全部產品
Search
文件中心

Application Real-Time Monitoring Service:Container ServiceACK環境自動安裝探針

更新時間:Jul 06, 2024

您只需安裝ARMS應用監控組件(探針)ack-onepilot,即可監控部署在Container ServiceKubernetes版中的Java應用,並查看應用拓撲、介面調用、異常事務和慢事務等相關監控資料。本文介紹如何為Container ServiceKubernetes版Java應用安裝探針。

前提條件

步驟一:安裝ARMS應用監控組件

重要

ACK舊版應用監控組件arms-pilot已不再維護,您可以安裝升級後的ack-onepilot組件用於監控您的應用,ack-onepilot完全相容arms-pilot,您無需修改應用配置即可無縫接入ack-onepilot。更多資訊,請參見如何安裝ack-onepilot和卸載arms-pilot

  1. 登入Container Service管理主控台

  2. 在左側導覽列單擊叢集,然後在叢集列表頁面單擊目的地組群名稱。

  3. 在左側導覽列選擇營運管理 > 組件管理,然後在右上方通過關鍵字搜尋ack-onepilot

  4. ack-onepilot卡片上單擊安裝

    說明

    ack-onepilot組件預設支援1000個pod規模,叢集pod每超過1000個,ack-onepilot資源對應的CPU請增加0.5核、記憶體請增加512 M。

  5. 在彈出的頁面中可以配置相關的參數,建議使用預設值,單擊確定

    說明

    安裝完成後,您可以在組件管理頁面升級、配置或卸載ack-onepilot組件。

步驟二:授予ARMS資源的存取權限

  • 如果需監控ASK(Container ServiceServerless版)或對接了ECI的叢集應用,請在雲資源訪問授權頁面完成授權,然後重啟ack-onepilot組件下的所有Pod。

  • 如果需監控ACK叢集應用,但ACK叢集中不存在ARMS Addon Token,請執行以下操作手動為叢集授予ARMS資源的存取權限。如果已經存在ARMS Addon Token,請跳轉至步驟三

    查看叢集是否存在ARMS Addon Token。

    1. 登入Container Service管理主控台,在叢集列表頁面,單擊目的地組群名稱進入叢集詳情頁。

    2. 在左側導覽列選擇組態管理 > 保密字典,然後在頂部選擇命名空間kube-system,查看addon.arms.token是否存在。

    說明

    叢集存在ARMS Addon Token時,ARMS會進行免密授權。Kubernetes託管版叢集預設存在ARMS Addon Token,但對於部分早期建立的Kubernetes託管版叢集,可能會存在沒有ARMS Addon Token的情況,因此,對於Kubernetes託管版叢集,建議首先檢查ARMS Addon Token是否存在。若不存在,需進行手動授權。

    1. 登入Container Service管理主控台

    2. 在左側導覽列選擇叢集,然後單擊目的地組群名稱。

    3. 在目的地組群的叢集資訊頁面單擊叢集資源頁簽,然後單擊Worker RAM角色右側的連結。

    4. 在角色頁面的許可權管理頁簽上,單擊新增授權

    5. 選擇許可權為AliyunARMSFullAccess,然後單擊確定

  • 如果需要監控專有版叢集和註冊叢集應用,請確認對應的阿里雲帳號已包含AliyunARMSFullAccessAliyunSTSAssumeRoleAccess許可權。添加許可權的操作,請參見為RAM使用者授權

    安裝ack-onepilot組件後,還需要在ack-onepilot中填寫有ARMS許可權的阿里雲帳號AK/SK。

    1. 在左側導覽列選擇應用 > Helm頁面,單擊ack-onepilot組件右側的更新

    2. accessKeyaccessKeySecret替換為當前帳號的AccessKey,然後單擊確定

      說明

      擷取AccessKey的操作,請參見建立AccessKey

      image

    3. 重啟應用Deployment。

步驟三:為Java應用開啟ARMS應用監控

如需在建立新應用的同時開啟ARMS應用監控,請完成以下操作。

  1. Container Service管理主控台左側導覽列單擊叢集,在叢集列表頁面上的目的地組群右側操作列單擊應用管理

  2. 無狀態頁面右上方單擊使用YAML建立資源

  3. 選擇樣本模板,並在模板(YAML格式)中將以下labels添加到spec.template.metadata層級下。

    labels:
      armsPilotAutoEnable: "on"
      armsPilotCreateAppName: "<your-deployment-name>"    #請將<your-deployment-name>替換為您的應用程式名稱。
      armsSecAutoEnable: "on"    #如果需要接入應用安全,則需要配置此參數。
    說明

    YAML Example

    建立一個無狀態(Deployment)應用並開啟ARMS應用監控的完整YAML樣本模板如下:

    展開查看完整樣本YAML檔案(Java)

    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:
          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: 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 
    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:
          labels:
            app: arms-springboot-demo-subcomponent
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-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
    ---

執行結果

無狀態頁面上,目標應用的操作列將出現ARMS控制台按鈕。

ARMS Console Button

常見問題