本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Spot 实例
托管节点组
eksctl
支持使用 EKS 托管节点组的竞价型工作节点
要使用竞价型实例创建带有托管节点组的集群,请传递该--spot
标志和可选的实例类型列表:
eksctl create cluster --spot --instance-types=c3.large,c4.large,c5.large
要在现有集群上使用竞价型实例创建托管节点组,请执行以下操作:
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
字段来配置竞价型实例。见下文
进一步信息
非托管节点组
eksctl
已通过 Auto Scaling Grou MixedInstancesPolicy ps 支持竞价型实例。
以下是使用 50% 竞价型实例和 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
此示例使用容量优化的竞价分配策略:
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 A EC2 uto Scaling 会尽最大努力尊重实例类型优先级,但会首先针对容量进行优化。对于必须最大限度地减少中断可能性的工作负载来说,这是一个不错的选择,但对某些实例类型的偏好也很重要。有关更多信息,请参阅 ASG 购买选项。
请注意,使用该spotInstancePools
字段时不应设置该spotAllocationStrategy
字段。如果未指定,则 EC2 将默认使用该lowest-price
策略。spotAllocationStrategy
以下是一个最小的例子:
nodeGroups: - name: ng-1 instancesDistribution: instanceTypes: ["t3.small", "t3.medium"] # At least one instance type should be specified
要区分竞价型实例和按需型实例之间的节点,您可以使用 kubernetes 标签node-lifecycle
,该标签将具有值spot
或on-demand
取决于其类型。
实例分布中的参数
有关详细信息,请参阅集群配置架构。