karpenter-provider-aws: No fallback to on-demand nodes when hitting MaxSpotInstanceCountExceeded
Description
Observed Behavior: Pods that prefer spot nodes are stuck in Pending because Karpenter does not spin up on-demand nodes when the spot instance quota is exceeded.
Expected Behavior: Karpenter provisions on-demand nodes when the spot instance quota is exceeded.
Relevant Logs:
2024-03-05 09:43:30.916 {"level":"WARN","time":"2024-03-05T14:43:30.916Z","logger":"controller.nodeclaim.lifecycle","message":"at least 5 instance types are recommended when flexible to spot but requesting on-demand, the current provisioning request only has 1 instance type options","commit":"2dd7fdc","nodeclaim":"interruptible-8zqwp"}
2024-03-05 09:43:20.793 {"level":"ERROR","time":"2024-03-05T14:43:20.793Z","logger":"controller.nodeclaim.lifecycle","message":"creating instance, insufficient capacity, with fleet error(s), InsufficientInstanceCapacity: We currently do not have sufficient c5a.2xlarge capacity in the Availability Zone you requested (us-east-1d). Our system will be working on provisioning additional capacity. You can currently get c5a.2xlarge capacity by not specifying an Availability Zone in your request or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1f.; UnfulfillableCapacity: Unable to fulfill capacity due to your request configuration. Please adjust your request and try again.; MaxSpotInstanceCountExceeded: Max spot instance count exceeded","commit":"2dd7fdc","nodeclaim":"interruptible-gkvns"}
2024-03-05 09:34:07.041 {"level":"ERROR","time":"2024-03-05T14:34:07.041Z","logger":"controller.disruption.queue","message":"failed to disrupt nodes, replacement was deleted, NodeClaim.karpenter.sh \"interruptible-fw7zn\" not found; waiting for replacement initialization, node claim not initialized","commit":"2dd7fdc","nodes":"ip-10-35-100-218.ec2.internal"}
2024-03-05 09:34:04.347 {"level":"WARN","time":"2024-03-05T14:34:04.346Z","logger":"controller.nodeclaim.lifecycle","message":"at least 5 instance types are recommended when flexible to spot but requesting on-demand, the current provisioning request only has 1 instance type options","commit":"2dd7fdc","nodeclaim":"interruptible-wmkfp"}
2024-03-05 09:34:03.576 {"level":"ERROR","time":"2024-03-05T14:34:03.576Z","logger":"controller.nodeclaim.lifecycle","message":"creating instance, insufficient capacity, with fleet error(s), MaxSpotInstanceCountExceeded: Max spot instance count exceeded","commit":"2dd7fdc","nodeclaim":"interruptible-fw7zn"}
2024-03-05 09:31:57.632 {"level":"WARN","time":"2024-03-05T14:31:57.632Z","logger":"controller.nodeclaim.lifecycle","message":"at least 5 instance types are recommended when flexible to spot but requesting on-demand, the current provisioning request only has 1 instance type options","commit":"2dd7fdc","nodeclaim":"interruptible-2lzvq"}
2024-03-05 09:31:49.989 {"level":"ERROR","time":"2024-03-05T14:31:49.989Z","logger":"controller.nodeclaim.lifecycle","message":"creating instance, insufficient capacity, with fleet error(s), UnfulfillableCapacity: Unable to fulfill capacity due to your request configuration. Please adjust your request and try again.","commit":"2dd7fdc","nodeclaim":"interruptible-jzlqz"}
2024-03-05 09:31:48.564 {"level":"ERROR","time":"2024-03-05T14:31:48.564Z","logger":"controller.nodeclaim.lifecycle","message":"creating instance, insufficient capacity, with fleet error(s), MaxSpotInstanceCountExceeded: Max spot instance count exceeded","commit":"2dd7fdc","nodeclaim":"interruptible-thllw"}
Node Pool Definition:
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
annotations:
meta.helm.sh/release-name: karpenter-interruptible-node-pool
meta.helm.sh/release-namespace: karpenter
name: interruptible
spec:
disruption:
consolidationPolicy: WhenUnderutilized
expireAfter: Never
limits:
cpu: "2500"
memory: 10000Gi
template:
metadata:
labels:
lifecycle: spot
spec:
nodeClassRef:
name: default
requirements:
- key: lifecycle
operator: Exists
- key: kubernetes.io/arch
operator: In
values:
- amd64
- key: kubernetes.io/os
operator: In
values:
- linux
- key: karpenter.sh/capacity-type
operator: In
values:
- spot
- on-demand
- key: karpenter.k8s.aws/instance-category
operator: In
values:
- m
- r
- c
- t
- key: karpenter.k8s.aws/instance-generation
operator: Gt
values:
- "1"
- key: karpenter.k8s.aws/instance-hypervisor
operator: In
values:
- nitro
- key: karpenter.k8s.aws/instance-cpu
operator: Gt
values:
- "4"
- key: karpenter.k8s.aws/instance-cpu
operator: Lt
values:
- "32"
startupTaints:
- effect: NoExecute
key: node.cilium.io/agent-not-ready
- effect: NoExecute
key: ebs.csi.aws.com/agent-not-ready
taints:
- effect: NoSchedule
key: spot-node
Related Issues: I found https://github.com/aws/karpenter-provider-aws/issues/4318 and https://github.com/aws/karpenter-provider-aws/issues/1556 that seemed to indicate that Karpenter already exists, but we aren’t seeing this fallback behavior.
Versions:
- Chart Version: v0.33.0
- Image Version: v0.33.0
- Kubernetes Version (
kubectl version): v1.27.9-eks-5e0fdde
Notes:
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
Gotcha, appreciate the background on those MRs.
So that’s the weird thing - I don’t see any evidence of tags changing on the security group we are targeting. I am going to consult my team to get more eyes on this and see if I’m missing anything.
Gotcha, that means that the Pending pods were likely the result of this constant deprovisioning rather than the inability to fallback to on-demand nodes - good to know. And copy on the “weight” feature, I will check that out.
Just did some digging. I can’t find any evidence that we were updating the NodePool or EC2NodeClass during that time period.
Unfortunately,
karpenter_nodeclaims_drifteddoesn’t seem to be available during that time (note to self: I need to track that down). I started looking at other metrics -karpenter_nodeclaims_created,karpenter_nodeclaims_terminated,karpenter_nodeclaims_disrupted- andkarpenter_nodeclaims_disruptedhas a “type” label that seems interesting. During that time period, I see two values for this label,driftandSecurityGroupDrift, and the value of the metric with each label is identical. I will look into whether the SecurityGroup changed in any way. Additionally, I found a similar issue that references subnet drift as a potential cause - I will look into that too.In these logs, I see a pattern of a new on-demand node class spun up, but then quickly terminated because of drift consolidation.
spot node claim hits quota
{"level":"ERROR","time":"2024-03-05T14:15:35.830Z","logger":"controller.nodeclaim.lifecycle","message":"creating instance, insufficient capacity, with fleet error(s), InsufficientInstanceCapacity: We currently do not have sufficient c6in.2xlarge capacity in the Availability Zone you requested (us-east-1d). Our system will be working on provisioning additional capacity. You can currently get c6in.2xlarge capacity by not specifying an Availability Zone in your request or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1f.; UnfulfillableCapacity: Unable to fulfill capacity due to your request configuration. Please adjust your request and try again.; MaxSpotInstanceCountExceeded: Max spot instance count exceeded","commit":"2dd7fdc","nodeclaim":"interruptible-tq9lf"}spot node claim is deleted
{"level":"INFO","time":"2024-03-05T14:15:35.861Z","logger":"controller.nodeclaim.termination","message":"deleted nodeclaim","commit":"2dd7fdc","nodeclaim":"interruptible-tq9lf","node":"","provider-id":""}new node claim is created
{"level":"INFO","time":"2024-03-05T14:15:43.133Z","logger":"controller.disruption","message":"created nodeclaim","commit":"2dd7fdc","nodepool":"interruptible","nodeclaim":"interruptible-hwzcn","requests":{"cpu":"2120m","memory":"3996Mi","pods":"8"},"instance-types":"c5.2xlarge, c5.4xlarge, c5a.2xlarge, c5a.4xlarge, c5ad.2xlarge and 80 other(s)"}new node claim is launched as on-demand claim
{"level":"INFO","time":"2024-03-05T14:15:45.049Z","logger":"controller.nodeclaim.lifecycle","message":"launched nodeclaim","commit":"2dd7fdc","nodeclaim":"interruptible-hwzcn","provider-id":"aws:///us-east-1d/i-0c8169813786a1ba4","instance-type":"t3a.2xlarge","zone":"us-east-1d","capacity-type":"on-demand","allocatable":{"cpu":"7910m","ephemeral-storage":"179Gi","memory":"29471Mi","pods":"44"}}on-demand node claim is initialized, new node is created
{"level":"INFO","time":"2024-03-05T14:17:22.698Z","logger":"controller.nodeclaim.lifecycle","message":"initialized nodeclaim","commit":"2dd7fdc","nodeclaim":"interruptible-hwzcn","provider-id":"aws:///us-east-1d/i-0c8169813786a1ba4","node":"ip-10-35-104-207.ec2.internal"}7 seconds later node associated with on-demand node claim is marked for deletion
{"level":"INFO","time":"2024-03-05T14:17:29.511Z","logger":"controller.disruption","message":"disrupting via drift replace, terminating 1 candidates ip-10-35-104-207.ec2.internal/t3a.2xlarge/on-demand and replacing with node from types m6a.2xlarge, r6a.2xlarge, m5zn.2xlarge, r7a.2xlarge, m6id.2xlarge and 80 other(s)","commit":"2dd7fdc"}node is tainted
{"level":"INFO","time":"2024-03-05T14:19:07.071Z","logger":"controller.node.termination","message":"tainted node","commit":"2dd7fdc","node":"ip-10-35-104-207.ec2.internal"}node is deleted
{"level":"INFO","time":"2024-03-05T14:19:14.951Z","logger":"controller.node.termination","message":"deleted node","commit":"2dd7fdc","node":"ip-10-35-104-207.ec2.internal"}node claim is deleted
{"level":"INFO","time":"2024-03-05T14:19:15.303Z","logger":"controller.nodeclaim.termination","message":"deleted nodeclaim","commit":"2dd7fdc","nodeclaim":"interruptible-hwzcn","node":"ip-10-35-104-207.ec2.internal","provider-id":"aws:///us-east-1d/i-0c8169813786a1ba4"}