我希望以这样的方式配置我的 Elastic Kubernetes 服务集群,只要可用,它将使用现货实例,如果现货实例不可用,它将使用普通的按需实例
如果您使用 Karpenter 作为集群自动缩放器,您可以通过在
on-demand
之后添加到配置程序要求中的 spot
容量类型来实现该缺陷功能:
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"]
我知道回答这个问题有点晚了,但这就是你想要做的,是我在这篇博客中描述的吗?