在 Arm 架構上部署 Autopilot 工作負載

本頁面說明如何設定 Google Kubernetes Engine (GKE) Autopilot 部署作業,要求以 Arm 架構為基礎的節點。

關於 Autopilot 中的 Arm 架構

Autopilot 叢集提供運算類別,可滿足有特定硬體需求的工作負載。部分運算類別支援多個 CPU 架構,例如 amd64arm64

Arm 節點的用途

與類似的 x86 節點相比,採用 Arm 架構的節點可提供更具成本效益的效能。在下列情況中,您應為 Autopilot 工作負載選取 Arm:

  • 您的環境依賴 Arm 架構進行建構和測試。
  • 您正在為搭載 Arm CPU 的 Android 裝置開發應用程式。
  • 您使用多架構映像檔,並希望在執行工作負載時盡可能提高成本效益。

事前準備

開始之前,請確認您已完成下列工作:

  • 啟用 Google Kubernetes Engine API。
  • 啟用 Google Kubernetes Engine API
  • 如要使用 Google Cloud CLI 執行這項工作,請安裝初始化 gcloud CLI。如果您先前已安裝 gcloud CLI,請執行 gcloud components update 指令,取得最新版本。較舊的 gcloud CLI 版本可能不支援執行本文件中的指令。
  • 查看 Arm 節點的規定和限制
  • 如要使用 autopilot-arm ComputeClass,請確認叢集執行的是 GKE 1.35.3-gke.1389000 以上版本。
  • 請確認您有 C4AN4ATau T2A Compute Engine 機型的配額。
  • 確認您有為 Arm 架構建構的容器映像檔 Pod。

如何在 Autopilot 中要求 Arm 節點

如要讓 Autopilot 在 Arm 節點上執行 Pod,請視需求採用下列其中一種方法。您可以使用 nodeSelector節點親和性規則指定這些項目:

  • 一般用途工作負載:指定下列兩者,要求使用以容器最佳化的 Arm 平台:
    • cloud.google.com/compute-class: autopilot-arm
    • kubernetes.io/arch: arm64
  • 針對有特定硬體需求的工作負載:指定下列其中一個選項:

    • kubernetes.io/arch: arm64。對於執行 1.31.3-gke.1056000 以上版本的叢集,GKE 預設會將 Pod 放在 C4A機器 類型上。 如果叢集執行的是舊版,GKE 會將 Pod 放置在 T2A 機型上。

    • cloud.google.com/machine-family: ARM_MACHINE_SERIES。 請將 ARM_MACHINE_SERIES 替換為 Arm 機器的系列,例如 C4AN4AT2A。GKE 會將 Pod 放置在指定的系列中。

根據預設,使用 Performance 以外的任何標籤,可讓 GKE 在節點有可用容量時,將其他 Pod 放在同一個節點上。如要為每個 Pod 要求專屬節點,請在資訊清單中加入 cloud.google.com/compute-class: Performance 標籤,以及架構或機器系列標籤。詳情請參閱「選擇機器系列,最佳化 Autopilot Pod 效能」。

或者,您也可以搭配使用 Scale-Outarm64 標籤,要求 T2A。 您也可以為 Spot Pod 要求 Arm 架構。

部署工作負載時,Autopilot 會執行下列操作:

  1. 自動佈建 Arm 節點來執行 Pod。
  2. 自動汙染新節點,防止非 Arm Pod 排程至這些節點。
  3. 自動為 Arm Pod 新增容許條件,允許在新節點上排程。

Arm 架構的要求範例

下列範例規格說明如何在 Autopilot 中使用節點選取器或節點親和性規則,要求 Arm 架構。

nodeSelector

以下範例資訊清單要求 Autopilot 容器最佳化 Arm 節點:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-arm
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-arm
  template:
    metadata:
      labels:
        app: nginx-arm
    spec:
      nodeSelector:
        cloud.google.com/compute-class: autopilot-arm
        kubernetes.io/arch: arm64
      containers:
      - name: nginx-arm
        image: nginx
        resources:
          requests:
            cpu: 2000m
            memory: 2Gi

如要要求特定硬體,而非 Autopilot 容器最佳化節點,請在 nodeSelector 中將 autopilot-arm 替換為 PerformanceScale-Out

nodeAffinity

您可以使用節點親和性要求 Arm 節點。

以下範例資訊清單要求 Autopilot 容器最佳化 Arm 節點:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-arm
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-arm
  template:
    metadata:
      labels:
        app: nginx-arm
    spec:
      terminationGracePeriodSeconds: 25
      containers:
      - name: nginx-arm
        image: nginx
        resources:
          requests:
            cpu: 2000m
            memory: 2Gi
            ephemeral-storage: 1Gi
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: cloud.google.com/compute-class
                operator: In
                values:
                - autopilot-arm
              - key: kubernetes.io/arch
                operator: In
                values:
                - arm64

如要要求特定硬體,而非 Autopilot 容器最佳化節點,請在 nodeAffinity 規則中將 autopilot-arm 替換為 PerformanceScale-Out

建議

  • 建構及使用多架構映像檔,做為管道的一部分。多架構映像檔可確保 Pod 即使放置在 x86 節點上,也能正常運作。
  • 在工作負載資訊清單中明確要求架構和運算類別。否則,Autopilot 會使用所選運算級別的預設架構,這可能不是 Arm。

可用性

您可以在下列區域的 Arm 架構上部署 Autopilot 工作負載:us-east1us-west1europe-west1europe-west4us-central1

疑難排解

如需常見錯誤和疑難排解資訊,請參閱「排解 Arm 工作負載問題」。

後續步驟