本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Spot 執行個體
受管節點群組
eksctl
支援使用 EKS 受管節點群組的 Spot 工作者節點
若要使用 Spot 執行個體建立具有受管節點群組的叢集,請傳遞 --spot
旗標和選用的執行個體類型清單:
eksctl create cluster --spot --instance-types=c3.large,c4.large,c5.large
若要在現有叢集上使用 Spot 執行個體建立受管節點群組:
eksctl create nodegroup --cluster=<clusterName> --spot --instance-types=c3.large,c4.large,c5.large
若要透過組態檔案使用受管節點群組建立 Spot 執行個體:
# spot-cluster.yaml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: spot-cluster region: us-west-2 managedNodeGroups: - name: spot instanceTypes: ["c3.large","c4.large","c5.large","c5d.large","c5n.large","c5a.large"] spot: true # `instanceTypes` defaults to [`m5.large`] - name: spot-2 spot: true # On-Demand instances - name: on-demand instanceTypes: ["c3.large", "c4.large", "c5.large"]
eksctl create cluster -f spot-cluster.yaml
注意
未受管節點群組不支援 spot
和 instanceTypes
欄位,而是使用 instancesDistribution
欄位來設定 Spot 執行個體。請參閱以下內容
詳細資訊
未受管節點群組
eksctl
支援透過適用於 Auto Scaling 群組的 MixedInstancesPolicy 的 Spot 執行個體。
以下是使用 50% Spot 執行個體和 50% 隨需執行個體的節點群組範例:
nodeGroups: - name: ng-1 minSize: 2 maxSize: 5 instancesDistribution: maxPrice: 0.017 instanceTypes: ["t3.small", "t3.medium"] # At least one instance type should be specified onDemandBaseCapacity: 0 onDemandPercentageAboveBaseCapacity: 50 spotInstancePools: 2
請注意,使用 nodeGroups.X.instanceType
欄位時,不應設定 instancesDistribution
欄位。
此範例使用 GPU 執行個體:
nodeGroups: - name: ng-gpu instanceType: mixed desiredCapacity: 1 instancesDistribution: instanceTypes: - p2.xlarge - p2.8xlarge - p2.16xlarge maxPrice: 0.50
此範例使用容量最佳化 Spot 配置策略:
nodeGroups: - name: ng-capacity-optimized minSize: 2 maxSize: 5 instancesDistribution: maxPrice: 0.017 instanceTypes: ["t3.small", "t3.medium"] # At least one instance type should be specified onDemandBaseCapacity: 0 onDemandPercentageAboveBaseCapacity: 50 spotAllocationStrategy: "capacity-optimized"
此範例使用capacity-optimized-prioritized配置策略:
nodeGroups: - name: ng-capacity-optimized-prioritized minSize: 2 maxSize: 5 instancesDistribution: maxPrice: 0.017 instanceTypes: ["t3a.small", "t3.small"] # At least two instance types should be specified onDemandBaseCapacity: 0 onDemandPercentageAboveBaseCapacity: 0 spotAllocationStrategy: "capacity-optimized-prioritized"
使用 capacity-optimized-prioritized
配置策略,然後在啟動範本覆寫清單中設定執行個體類型的順序,從最高到最低的優先順序 (清單先到最後)。Amazon EC2 Auto Scaling 會竭盡全力遵循執行個體類型優先順序,但會先針對容量最佳化。對於必須將中斷可能性降至最低的工作負載而言,這是理想的選項,但對於某些執行個體類型的偏好也很重要。如需詳細資訊,請參閱 ASG 購買選項。
請注意,使用 spotInstancePools
欄位時不應設定 spotAllocationStrategy
欄位。如果spotAllocationStrategy
未指定 ,EC2 預設會使用 lowest-price
策略。
以下是一個最少的範例:
nodeGroups: - name: ng-1 instancesDistribution: instanceTypes: ["t3.small", "t3.medium"] # At least one instance type should be specified
若要區分 Spot 或隨需執行個體之間的節點,您可以使用具有 值node-lifecycle
的 kubernetes 標籤spot
,或on-demand
取決於其類型。
instancesDistribution 中的參數
如需詳細資訊,請參閱叢集組態結構描述。