karpenter-provider-aws icon indicating copy to clipboard operation
karpenter-provider-aws copied to clipboard

feat: Dynamic EBS `volumeSize` in `EC2NodeClass`

Open pmcenery-bl opened this issue 7 months ago • 1 comments

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?

  • [X] 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 avatar Apr 29 '25 14:04 pmcenery-bl

Deploy Preview for karpenter-docs-prod ready!

Name Link
Latest commit 2e56b1390f36445bfaed86b5e99abd316564f4af
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.

netlify[bot] avatar Apr 29 '25 15:04 netlify[bot]