Skip to content

feat: Dynamic EBS volumeSize in EC2NodeClass #8024

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pmcenery-bl
Copy link

Fixes #8023

Summary:
This pull request enhances the EC2NodeClass functionality by allowing the volumeSize field to be dynamically calculated based on the number of CPUs in the node. This change introduces flexibility in configuring EBS volume sizes, reducing disk space waste and simplifying configuration.

Changes:

  1. Dynamic Volume Size Calculation:

    • The CalculateVolumeSize function now supports parsing the volumeSize field to calculate the size dynamically using the CPU keyword.
    • Example:
      • volumeSize: "10Gi * CPU" calculates the volume size as 10Gi multiplied by the number of CPUs in the node.
      • Static values like volumeSize: "20Gi" are still supported for backward compatibility.
  2. Unit Tests:

    • Added comprehensive unit tests in ec2nodeclass_test.go to validate the behavior of the CalculateVolumeSize function.
    • Test cases include:
      • Static volume sizes.
      • Dynamic volume sizes using CPU-based formulas.
      • Invalid formulas to ensure graceful handling.

Benefits:

  • Efficiency: Reduces disk space waste by scaling volume sizes dynamically with the node's CPU count.
  • Simplicity: Eliminates the need for multiple EC2NodeClass definitions for different node sizes, streamlining configuration.

Testing:

  • Unit tests have been added to validate the functionality for various scenarios.
  • To run the tests, use the following command:
    go test ./pkg/apis/v1 -v
    

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.

@pmcenery-bl pmcenery-bl requested a review from a team as a code owner April 29, 2025 14:58
Copy link

netlify bot commented Apr 29, 2025

Deploy Preview for karpenter-docs-prod ready!

Name Link
🔨 Latest commit 2e56b13
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/6811d710e9c29e0008710819
😎 Deploy Preview https://deploy-preview-8024--karpenter-docs-prod.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pmcenery-bl pmcenery-bl force-pushed the add-calculate-volume-size-tests branch from 3bb6afe to 2e56b13 Compare April 30, 2025 07:53
@jonathan-innis jonathan-innis added needs-triage Issues that need to be triaged triage/needs-owner Indicates that the issue needs an owner to address it and removed needs-triage Issues that need to be triaged labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/needs-owner Indicates that the issue needs an owner to address it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node disk size based on a formula of CPUs
2 participants