Skip to content

Conversation

@jbazkar
Copy link

@jbazkar jbazkar commented Nov 12, 2025

…min(maxPods, ENI limit) per #8497

Fixes #N/A

Description

  • Added helper to compute floor(min(MaxPods, ENI limit)) for kubeReserved calculation.
  • Added option to bypass kubeReserved auto-calculation when AMI family is Custom.
  • Updated NewInstanceType logic to respect these behaviors for Custom AMIs.
  • Preserves existing behavior for AL2/AL2023 families.
  • Previously, kubeReserved used ENI-limited memory overhead unconditionally, causing excessive allocable reduction (~8 GiB for high pod densities).
    This change provides flexibility for Custom AMI users and improves accuracy in allocable estimation when user-defined maxPods is lower than the ENI limit.
    -This PR focuses on logic correctness and configurability.
    -If approved, follow-up PRs can adjust test expectations and documentation for kubeReserved behavior in Custom AMI families.
    How was this change tested?
    Local test suite executed under envtest:
    • 92/98 tests passed
    • 6 integration tests (expected to fail) assert ENI-based maxPods and overhead — these will need update once the new behavior is accepted.
  • Core compilation and unit validation via go vet and go fmt are clean.
    Does this change impact docs?
  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…min(maxPods, ENI limit) per aws#8497

Signed-off-by: Baskaran Jeyarajan <[email protected]>
@jbazkar jbazkar requested a review from a team as a code owner November 12, 2025 08:58
@jbazkar jbazkar requested a review from ryan-mist November 12, 2025 08:58
@netlify
Copy link

netlify bot commented Nov 12, 2025

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit fc026fd
🔍 Latest deploy log https://app.netlify.com/projects/karpenter-docs-prod/deploys/69144c3718eed90008b05654

@jbazkar
Copy link
Author

jbazkar commented Nov 25, 2025

@ryan-mist Following up on this PR. Please advise if there are any updates or further changes needed on my side. I’m happy to make revisions or add additional validation as required. Thank you.

@ryan-mist
Copy link
Contributor

Added option to bypass kubeReserved auto-calculation when AMI family is Custom.

I'm a bit confused on this part, it was my assumption that this is already done currently if you pass in custom kubeReserved values?

Currently (the code is here) we override the calculated values if kube reserved is passed in:

return lo.Assign(resources, lo.MapEntries(kubeReserved, func(k string, v string) (corev1.ResourceName, resource.Quantity) {
		return corev1.ResourceName(k), resource.MustParse(v)
}))


if amiFamily.FeatureFlags().UsesENILimitedMemoryOverhead {
switch {
case p != nil && eni != nil && p.Value() > 0 && eni.Value() > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where p or eni can be nil or negative?

We may be able to simplify:

p := pods(ctx, info, amiFamily, maxPods, podsPerCore)
lo.Ternary(amiFamily.FeatureFlags().UsesENILimitedMemoryOverhead, lo.Min([]int{ENILimitedPods(ctx, info, 0), p}), p)

@jbazkar
Copy link
Author

jbazkar commented Dec 4, 2025

@ryan-mist Thank you for taking your time and providing the review comments. I’ll look into it shortly and send you an update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants