Skip to content

Conversation

@LiangquanLi930
Copy link
Contributor

@LiangquanLi930 LiangquanLi930 commented Oct 15, 2025

✨ Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity and NodeInfo

What type of PR is this?
/kind feature

What this PR does / why we need it:
This PR implements the Cluster API autoscaling from zero proposal for CAPA by adding a controller that automatically populates AWSMachineTemplate.Status.Capacity with instance type information.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 15, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign richardcase for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 15, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @LiangquanLi930. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@LiangquanLi930 LiangquanLi930 changed the title ✨ Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity WIP ✨ Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity Oct 15, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 15, 2025
@elmiko
Copy link

elmiko commented Oct 15, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 15, 2025
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch 7 times, most recently from f1ee365 to 3be8f4d Compare October 20, 2025 11:21
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 20, 2025
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch 2 times, most recently from 01be987 to 915f55b Compare October 20, 2025 12:57
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 20, 2025
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch from 915f55b to b3850d1 Compare October 20, 2025 14:42
@k8s-ci-robot k8s-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 20, 2025
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch 3 times, most recently from 2a9823c to 63118be Compare November 10, 2025 16:37
@LiangquanLi930
Copy link
Contributor Author

@richardcase @nrb @chrischdi Thanks for your review again! When you have time, could you help to review again? Thanks!

@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch 2 times, most recently from 10f3258 to 00485e3 Compare November 12, 2025 19:15
@damdo
Copy link
Member

damdo commented Nov 13, 2025

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 13, 2025
return ctrl.NewControllerManagedBy(mgr).
For(&infrav1.AWSMachineTemplate{}).
WithOptions(options).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log.GetLogger(), r.WatchFilterValue)).
Copy link
Member

@damdo damdo Nov 13, 2025

Choose a reason for hiding this comment

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

@chrischdi is this predicates.ResourceNotPausedAndHasFilterLabel the new equivalent to paused.EnsurePausedCondition later on in the reconcile loop ? I guess it is similar but behaves differently as the paused.EnsurePausedCondition check allows for doing extra steps before deciding to stop reconciling the resource right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, these two (the predicate and the EnsurePausedCondition function) are supposed to work together.

Copy link
Member

Choose a reason for hiding this comment

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

So are we saying we need @LiangquanLi930 to also add paused.EnsurePausedCondition ?

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/lgtm

One nit.

I won't add an approve because I'm not a maintainer.

Note: I did not fully review if the unit tests cover all reasonable cases or if they should be expanded.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 71a6824f8c228b2fff65322ecb245a02a075d5ca

@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch from 00485e3 to b398ffc Compare November 13, 2025 14:21
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

…deInfo

Add AWSMachineTemplateReconciler to automatically populate capacity and node
info fields by querying AWS EC2 API. This completes the autoscaling from zero
implementation by ensuring the required metadata is available without manual
configuration.

Changes include:
- Add NodeInfo struct with Architecture and OperatingSystem fields to AWSMachineTemplate status
- Implement controller that queries EC2 API for instance type specifications
- Auto-populate CPU, memory, pods, and ephemeral storage capacity
- Auto-detect architecture (amd64/arm64) and OS (linux/windows) from AMI
- Add conversion logic for backward compatibility with v1beta1
- Enable status subresource on AWSMachineTemplate CRD
- Add comprehensive unit tests (351 lines) covering various scenarios
- Add RBAC permissions for controller operations

The controller automatically populates these fields when an AWSMachineTemplate
is created or updated, eliminating the need for manual configuration and
enabling Cluster Autoscaler to make informed scaling decisions from zero nodes.

Related: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20210310-opt-in-autoscaling-from-zero.md

Squashed from 5 commits:
- 9a92a43 Implement autoscaling from zero by auto-populating AWSMachineTemplate capacity
- 86fe072 add AWSMachineTemplate NodeInfo
- ddaf62c Fix review comments
- 4ea52c8 Fix review comments 2
- b398ffc Fix review comments 3
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch from b398ffc to c0657c7 Compare November 13, 2025 15:26
@LiangquanLi930
Copy link
Contributor Author

squash commits

@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch from df0338b to 351ee0d Compare November 13, 2025 17:17
@LiangquanLi930 LiangquanLi930 force-pushed the opt-in-autoscaling-from-zero branch from 351ee0d to 641a0ca Compare November 13, 2025 18:15
@k8s-ci-robot
Copy link
Contributor

@LiangquanLi930: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-aws-e2e 3bf0acb link false /test pull-cluster-api-provider-aws-e2e
pull-cluster-api-provider-aws-test 641a0ca link true /test pull-cluster-api-provider-aws-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants