

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 建立 NodePool
<a name="sagemaker-hyperpod-eks-autoscaling-nodepool"></a>

`NodePool` 會對 Karpenter 可以建立的節點和可以在這些節點上執行的 Pod 設定限制條件。`NodePool` 可以設定為執行如下動作：
+ 將節點建立限制為特定區域、執行個體類型和電腦架構。
+ 定義標籤或污點，以限制可在 Karpenter 建立的節點上執行的 Pod。

**注意**  
HyperPod 提供者支援一組有限的知名 Kubernetes 和 Karpenter 要求，如下所述。

下列步驟涵蓋如何建立 `NodePool`。

1. 使用所需的 `NodePool` 組態建立名為 nodepool.yaml 的 YAML 檔案。

1. 您可以使用以下範例組態。

   在 `Conditions` 下尋找 `Ready`，表示所有相依資源都正常運作。

   ```
   apiVersion: karpenter.sh/v1
   kind: NodePool
   metadata:
    name: sample-np
   spec:
    template:
      spec:
        nodeClassRef:
         group: karpenter.sagemaker.amazonaws.com
         kind: HyperpodNodeClass
         name: multiazc5
        expireAfter: Never
        requirements:
           - key: node.kubernetes.io/instance-type
             operator: Exists
   ```

1. 將 `NodePool` 套用至您的叢集。

   ```
   kubectl apply -f nodepool.yaml
   ```

1. 監控 `NodePool` 狀態以確保狀態中的 `Ready` 條件設定為 `True`：

   ```
   kubectl get nodepool sample-np -oyaml
   ```

   ```
   apiVersion: karpenter.sh/v1
   kind: NodePool
   metadata:
     name: <nodepool-name>
     uid: <resource-uid>
     ...
   spec:
     disruption:
       budgets:
       - nodes: 90%
       consolidateAfter: 0s
       consolidationPolicy: WhenEmptyOrUnderutilized
     template:
       spec:
         expireAfter: 720h
         nodeClassRef:
           group: karpenter.sagemaker.amazonaws.com
           kind: HyperpodNodeClass
           name: <nodeclass-name>
         requirements:
         - key: node.kubernetes.io/instance-type
           operator: Exists
   status:
     conditions:
     - lastTransitionTime: "<timestamp>"
       message: ""
       observedGeneration: 2
       reason: ValidationSucceeded
       status: "True"
       type: ValidationSucceeded
     - lastTransitionTime: "<timestamp>"
       message: ""
       observedGeneration: 2
       reason: NodeClassReady
       status: "True"
       type: NodeClassReady
     - lastTransitionTime: "<timestamp>"
       message: ""
       observedGeneration: 2
       reason: Ready
       status: "True"
       type: Ready
   ```

**Karpenter HyperPod 提供者支援的標籤**

這些是您可以在 `NodePool` 組態中指定的選用限制條件和要求。


|  要求類型  |  用途  |  使用案例/支援的值  |  建議  | 
| --- | --- | --- | --- | 
|  執行個體類型 (`node.kubernetes.io/instance-type`)  |  控制 Karpenter 可以從中選擇的 SageMaker 執行個體類型  |  不限於 ml.c5.xlarge，而是讓 Karpenter 從執行個體群組中的所有可用類型中挑選  |  將此保持未定義或使用 Exists 運算子，為 Karpenter 在選擇符合成本效益的執行個體類型時提供最大的彈性  | 
|  可用區域 (`topology.kubernetes.io/zone`)  |  控制可以在 中建立哪些 AWS 可用區域節點  |  特定區域名稱，例如 us-east-1c。當您由於延遲或合規原因而需要在特定區域中執行 Pod 時使用  | N/A | 
|  架構 (`kubernetes.io/arch`)  |  指定 CPU 架構  |  僅限 amd64 (目前不支援任何 ARM)  |  N/A  | 