在 Azure Stack HCI 23H2) 上管理叢集 (AKS 的節點集區

適用於:Azure Stack HCI 版本 23H2

注意

如需在 Azure Stack HCI 22H2 上的 AKS 中管理節點集區的相關信息,請參閱 管理節點集區

在 Azure Arc 所啟用的 AKS 中,相同組態的節點會群組在一起成為 節點集區。 這些節點集區包含用來執行應用程式的基礎 VM。 本文說明如何在 AKS Arc 中建立和管理叢集的節點集區。

建立 Kubernetes 叢集

若要開始使用,請使用單一節點集區建立 Kubernetes 叢集:

az aksarc create -n <cluster name> -g <resource group> --custom-location <custom location Id> --vnet-ids <vnet id> --generate-ssh-keys --load-balancer-count <load balancer count>

新增節點集區

您可以使用 命令,將節點集區新增至現有的叢集 az aksarc nodepool add 。 請確定節點集區的名稱與現有節點集區的名稱不同:

az aksarc nodepool add --name <node pool name> -g <resource group> --cluster-name <cluster name> --os-sku <Linux or Windows> --node-count <count> --node-vm-size <vm size>

取得節點集區的組態資訊

若要查看節點集區的設定,請使用 az aksarc nodepool show 命令:

az aksarc nodepool show --cluster-name <cluster name> -n <node pool name> -g <resource group>

範例輸出︰

{
"availabilityZones": null,
"count": 1,
"extendedLocation": null,
"id":
"/subscriptions/&lt;subscription&gt;/resourceGroups/edgeci-registration-rr1s46r1710&lt;resource
group&gt;/providers/Microsoft.Kubernetes/connectedClusters/&lt;cluster
name&gt;/providers/Microsoft.HybridContainerService/provisionedClusterInstances/default/agentPools/&lt;nodepoolname&gt;",
"location": "westeurope",
"name": "nodepoolname",
"nodeImageVersion": null,
"osSku": "CBLMariner",
"osType": "Linux",
"provisioningState": "Succeeded",
"resourceGroup": "resourcegroup",
"status": {
  "errorMessage": null,
  "operationStatus": null,
  "readyReplicas": [
   {
    "count": 1,
    "vmSize": "Standard\_A4\_v2"
   }
  ]
},
"systemData": {
…
},
"tags": null,
"type":
"microsoft.hybridcontainerservice/provisionedclusterinstances/agentpools",
"vmSize": "Standard\_A4\_v2"
}

指定部署至節點集區的最大 Pod

您可以在叢集建立期間或建立新的節點集區時,設定可部署到節點的最大 Pod。 如果您未指定 maxPods 建立節點集區時,您的節點集區會部署預設值上限為 110 個 Pod:

az aksarc nodepool add --cluster-name <cluster name> -n <node pool name> -g <resource group> --max-pods 50 --yes

縮放節點集區

您可以增加或減少節點集區的節點數目。

若要調整節點集區中的節點數目,請使用 az aksarc nodepool scale 命令。 下列範例會在名為 nodepool1的節點集區中,將節點數目調整為 2:

az aksarc nodepool scale --cluster-name <cluster name> -n nodepool1 -g <resource group> --node-count 2 --yes

刪除節點集區

如果您需要刪除節點集區,請使用 az aksarc nodepool delete 命令:

az aksarc nodepool delete --cluster-name <cluster name> -n <node pool name> -g <resource group> --yes

指定節點集區的 Taint 或標籤

當您建立節點集區時,您可以將 Taint 或標籤新增至該集區。 當您新增 taint 或標籤時,該節點集區內的所有節點也會取得該點或標籤。

重要

您應該使用 az aksarc nodepool將擷取或標籤新增至整個節點集區的節點。 不建議使用 將 kubectl 點數或標籤套用至節點集區中的個別節點。

設定節點集區擷取

  1. 使用 命令建立具有 taint 的 az aksarc nodepool add 節點集區。 指定名稱 taintnp--node-taints 並使用 參數來指定 sku=gpu:NoSchedule taint:

    az aksarc nodepool add \
        --resource-group myResourceGroup \
        --cluster-name myAKSCluster \
        --name taintnp \
        --node-count 1 \
        --node-taints sku=gpu:NoSchedule \
        --no-wait
    
  2. 使用 az aksarc nodepool list 命令檢查節點集區的狀態:

    az aksarc nodepool list -g myResourceGroup --cluster-name myAKSCluster
    

    下列範例輸出顯示 taintnp 節點集區會使用指定的 nodeTaints來建立節點:

    [
      {
        ...
        "count": 1,
        ...
        "name": "taintnp",
        ...
        "provisioningState": "Succeeded",
        ...
        "nodeTaints":  [
          "sku=gpu:NoSchedule"
        ],
        ...
      },
     ...
    ]
    

在 Kubernetes 中會顯示污點資訊,以處理節點的排程規則。 Kubernetes 排程器可以使用 Taint 和 Toleration 來限制哪些工作負載可以在節點上執行。

  • 污點會套用至節點,該節點指示僅可以在其上排程特定的 pod。
  • 接著 會套用Toleration 至Pod,讓Pod能夠「容許」節點的Taint。

設定節點集區容許

在上一個步驟中,您已在建立節點集區時套用 sku=gpu:NoSchedule taint。 下列範例 YAML 指令清單會使用 Toleration 來允許 Kubernetes 排程器在該節點集區中的節點上執行 NGINX Pod:

  1. 建立名為 nginx-toleration.yaml 的檔案,並複製/貼上下列範例 YAML:

    apiVersion: v1
    kind: Pod
    metadata:
      name: mypod
    spec:
      containers:
      - image: mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine
        name: mypod
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 1
            memory: 2G
      tolerations:
      - key: "sku"
        operator: "Equal"
        value: "gpu"
        effect: "NoSchedule"
    
  2. 使用 kubectl apply 命令來排程 Pod:

    kubectl apply -f nginx-toleration.yaml
    

    排程 Pod 並提取 NGINX 映像需要幾秒鐘的時間。

  3. 使用 kubectl describe pod 命令檢查狀態:

    kubectl describe pod mypod
    

    下列壓縮的範例輸出顯示 sku=gpu:NoSchedule 已套用Toleration。 在 [ 事件 ] 區段中,排程器已將 Pod 指派給 moc-lbeof1gn6x3 節點:

    [...]
    Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                     node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
                     sku=gpu:NoSchedule
    Events:
      Type    Reason     Age    From                Message
      ----    ------     ----   ----                -------
      Normal  Scheduled  54s  default-scheduler   Successfully assigned default/mypod to moc-lbeof1gn6x3
      Normal  Pulling    53s  kubelet             Pulling image "mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine"
      Normal  Pulled     48s  kubelet             Successfully pulled image "mcr.microsoft.com/oss/nginx/nginx:1.15.9-alpine" in 3.025148695s (3.025157609s including waiting)
      Normal  Created    48s  kubelet             Created container
      Normal  Started    48s  kubelet             Started container
    

    只有套用此容忍的 Pod 可以在 中的 taintnp節點上排程。 任何其他 Pod 會排程在 nodepool1 節點集區中。 如果您建立更多節點集區,您可以使用 Taint 和 Toleration 來限制這些節點資源上可排程的 Pod。

設定節點集區標籤

如需詳細資訊,請參閱 在已啟用 Azure Arc 的 AKS 叢集中使用標籤。 ::: zone-end

下一步