我想配置我的Elastic Kubernetes服务集群,使其在任何可用的时候都使用spot实例,如果spot实例不可用,则使用正常的按需实例
如果您使用Karpenter作为集群自动缩放器,您可以通过在spot
:之后添加到需要on-demand
容量类型的provisioner来实现这种回退功能
key: "karpenter.sh/capacity-type" # If not included, the webhook for the AWS cloud provider will default to on-demand
operator: In
values: ["spot", "on-demand"]
参见完整示例(相关部分是需求中的最后一个关键(:
apiVersion: karpenter.sh/v1alpha5
kind: Provisioner
metadata:
name: default
spec:
# If nil, the feature is disabled, nodes will never expire
ttlSecondsUntilExpired: 2592000 # 30 Days = 60 * 60 * 24 * 30 Seconds;
# If nil, the feature is disabled, nodes will never scale down due to low utilization
ttlSecondsAfterEmpty: 30
# Provisioned nodes will have these taints
# Taints may prevent pods from scheduling if they are not tolerated
taints:
- key: example.com/special-taint
effect: NoSchedule
# Labels are arbitrary key-values that are applied to all nodes
labels:
billing-team: my-team
# Requirements that constrain the parameters of provisioned nodes.
# These requirements are combined with pod.spec.affinity.nodeAffinity rules.
# Operators { In, NotIn } are supported to enable including or excluding values
requirements:
- key: "node.kubernetes.io/instance-type"
operator: In
values: ["m5.large", "m5.2xlarge"]
- key: "topology.kubernetes.io/zone"
operator: In
values: ["us-west-2a", "us-west-2b"]
- key: "kubernetes.io/arch"
operator: In
values: ["arm64", "amd64"]
- key: "karpenter.sh/capacity-type" # If not included, the webhook for the AWS cloud provider will default to on-demand
operator: In
values: ["spot", "on-demand"]