全部產品
Search
文件中心

Application Real-Time Monitoring Service:Container ServiceACK和容器計算服務ACS通過ack-onepilot組件安裝Java探針

更新時間:Feb 15, 2025

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

說明

Container Service Kubernetes 版ACKContainer Compute ServiceACS安裝探針的操作相同,本文以Container Service Kubernetes 版ACK為例示範安裝探針的操作。

ack-onepilot組件說明

ARMS探針接入助手(ack-onepilot)是用於接入各語言探針的重要組件,可以協助ARMS使用者在容器環境中自動準備好ARMS探針包並構建好探針的上報環境。ARMS探針接入助手(ack-onepilot)的基本原理請參見ack-onepilot組件基本原理說明

探針接入後,為了確保您的使用體驗,在新版本探針發布後,當應用重啟時,ack-onepilot將會自動將探針升級到最新版本,如果您不需要跟隨ARMS探針的版本發布自動更新掛載的探針,可以自主控制探針版本。具體操作,請參見自主控制探針版本

重要

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

前提條件

步驟一:安裝ARMS探針接入助手(ack-onepilot)

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

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

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

    說明

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

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

    說明

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

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

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. 叢集資訊 > 基本資料頁簽的叢集資源地區,單擊Worker RAM角色右側的連結。

  3. 許可權管理頁簽單擊新增授權

  4. 新增授權面板添加以下兩個權限原則,然後單擊確認新增授權

    • AliyunTracingAnalysisFullAccess:Managed Service for OpenTelemetry的完整許可權。

    • AliyunARMSFullAccess:ARMS的完整許可權。

專有版叢集/註冊叢集

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

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

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

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

    說明

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

    為降低AccessKey泄露的風險,阿里雲帳號(主帳號)的AccessKey Secret只在建立時顯示,後續不支援查看,請妥善保管。

    image

  3. 重啟應用Deployment。

ASK/ECI叢集

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

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

建立一個無狀態(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
---
  1. 登入Container Service管理主控台,在左側導覽列選擇叢集列表

  2. 叢集列表頁面左側頂部,選擇目的地組群所在的資源群組和地區,單擊目的地組群名稱,然後在左側導覽列,選擇工作負載 > 無狀態

  3. 無狀態頁面的目標應用右側選擇更多 > 查看Yaml

    如需建立一個新應用,單擊使用YAML建立資源

  4. 在YAML檔案中將以下labels添加到spec.template.metadata層級下。

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

    YAML Example

  5. 單擊建立

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

    ARMS Console Button

常見問題