Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karpenter pod capacity exceeds available IPs from ENIs with other CNIs #5780

Open
cnmcavoy opened this issue Mar 4, 2024 · 3 comments · May be fixed by #6042
Open

Karpenter pod capacity exceeds available IPs from ENIs with other CNIs #5780

cnmcavoy opened this issue Mar 4, 2024 · 3 comments · May be fixed by #6042
Labels
feature New feature or request

Comments

@cnmcavoy
Copy link
Contributor

cnmcavoy commented Mar 4, 2024

Description

Observed Behavior: We've observed Karpenter creates nodes with a pod capacity higher than is actually supported by the instance type's ENI's. We observed this most recently with a "g4ad.4xlarge" instance node, which with our Karpenter configuration (reserved ENIs = 1) was assigned a pod capacity of "20" pods, however, we had a pod that was not able to start, and after investigating, it was unable to be assigned an IP from Cilium.

We run clusters with Cilium and use Cilium to replace kube-proxy, so there are no kube-proxy pods that run on our nodes. When we were debugging this behavior we noticed that the calculation Karpenter uses for the node's pod capacity is based on this:

#
# Mapping is calculated from AWS EC2 API using the following formula:
# * First IP on each ENI is not used for pods
# * +2 for the pods that use host-networking (AWS CNI and kube-proxy)
#
#   # of ENI * (# of IPv4 per ENI - 1) + 2
#
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI
#

This does come out to 20 when supplying the variables for the g4ad.4xlarge: (3 ENIs - 1 Reserved) * (10 - 1) + 2 = 20. So Karpenter is following this formula, however, if there's no kube-proxy pod and only 1 CNI pod, then would that make this math wrong?

Expected Behavior: Expected the node's pod capacity to match the number of pods that can run on the node.

Reproduction Steps (Please include YAML): N/A

Versions:

  • Chart Version: v0.34.0
  • Kubernetes Version (kubectl version): v1.26.12-eks-5e0fdde
  • 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
@cnmcavoy cnmcavoy added bug Something isn't working needs-triage Issues that need to be triaged labels Mar 4, 2024
@njtran
Copy link
Contributor

njtran commented Mar 4, 2024

Can you explain more about how Cilium's (and maybe other CNIs too) calculation of maxPods differs from the AWS calculation? Is it also a static value like a +2 but Cilium is something like +3? Is this something that scales by instance size/type?

@cnmcavoy
Copy link
Contributor Author

cnmcavoy commented Mar 4, 2024

My interpretation of:

#   # of ENI * (# of IPv4 per ENI - 1) + 2

is that the final "+2" comes from this comment:

# * +2 for the pods that use host-networking (AWS CNI and kube-proxy)

We don't have kube-proxy pods, only cilium pods are using host networking. So should this be a +1 for Cilium or anyone who has kube-proxy disabled?

@njtran njtran added feature New feature or request and removed bug Something isn't working needs-triage Issues that need to be triaged labels Mar 11, 2024
@cnmcavoy
Copy link
Contributor Author

cnmcavoy commented Jun 11, 2024

I disagree that this is a feature request. Without this resolved, using ENI IPAM, you can enter states where pods can schedule to a node and never start due to a node's pod capacity being set higher than a node's ENI capacity. If that is intended Karpenter operation this behavior should be documented somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
2 participants