Skip to content

feat(recommender): add enforce cpu memory ratio #8420

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: master
Choose a base branch
from

Conversation

Jrmy2402
Copy link

@Jrmy2402 Jrmy2402 commented Aug 8, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds --enforce-cpu-memory-ratio flag to the VPA recommender, allowing users to enforce a fixed memory-per-CPU ratio (expressed as bytes per millicores) across all resource recommendations.
This ensures that CPU and memory recommendations remain balanced according to a user-defined ratio, automatically adjusting one resource when the other changes.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The ratio is applied to Target, LowerBound, UpperBound, and UncappedTarget recommendations.
The value of --enforce-cpu-memory-ratio should be specified in bytes per millicores (e.g., 4294967.296 for 1 CPU → 4 GiB).

feat(recommender): add enforce cpu memory ratio

@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. labels Aug 8, 2025
Copy link

linux-foundation-easycla bot commented Aug 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-area labels Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @Jrmy2402!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Jrmy2402. Thanks for your PR.

I'm waiting for a kubernetes 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.

@k8s-ci-robot k8s-ci-robot added area/vertical-pod-autoscaler size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-area labels Aug 8, 2025
@Jrmy2402 Jrmy2402 force-pushed the enforce-cpu-memory-ratio branch from d914a14 to 1986edf Compare August 8, 2025 11:54
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 8, 2025
@Jrmy2402 Jrmy2402 force-pushed the enforce-cpu-memory-ratio branch 2 times, most recently from 5a27892 to 37f23aa Compare August 8, 2025 12:11
@omerap12
Copy link
Member

omerap12 commented Aug 8, 2025

Thanks for this!
I didn't review it yet but I thought new flags should be behind a feature flag?
@adrianmoisey

@jackfrancis
Copy link
Contributor

/release-note feat(recommender): add enforce cpu memory ratio

@adrianmoisey
Copy link
Member

/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 Aug 9, 2025
@adrianmoisey
Copy link
Member

I'm wondering if this change makes sense as a flag. It seems that moving these sorts of configurable option to the VPA API would seem to be more desirable, as a user may want to enable this on a subset of workloads controlled by the VPA

@omerap12
Copy link
Member

omerap12 commented Aug 9, 2025

desirable, as a user may want to enable this on a subset of workloads controlled by the VPA

Yeah totally agree here.

@Jrmy2402
Copy link
Author

Ok, thanks for the review. I'll rework the MR to handle this via the VPA API.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Jrmy2402
Once this PR has been reviewed and has the lgtm label, please assign raywainman 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

@Jrmy2402 Jrmy2402 force-pushed the enforce-cpu-memory-ratio branch from 1db9ede to 7786c6f Compare August 12, 2025 09:52
@Jrmy2402 Jrmy2402 force-pushed the enforce-cpu-memory-ratio branch 2 times, most recently from 2f22344 to a3ea8ba Compare August 12, 2025 11:50
@Jrmy2402 Jrmy2402 force-pushed the enforce-cpu-memory-ratio branch from a3ea8ba to 0a85516 Compare August 12, 2025 12:00
@Jrmy2402
Copy link
Author

Update: switched from the global --enforce-cpu-memory-ratio flag to the new MemoryPerCPU field in the VPA API (configurable per container in PodResourcePolicy).

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 12, 2025
@omerap12
Copy link
Member

This should be behind an alpha feature flag with default off

@adrianmoisey
Copy link
Member

Does this type of change need an AEP? I assume so, since it's an API change. Sorry for the extra scope.

@Jrmy2402
Copy link
Author

Ok I will add an alpha feature flag with default off next week.
For the AEP, I need to check what I need to do, I have never done it before

@omerap12
Copy link
Member

Ok I will add an alpha feature flag with default off next week.

For the AEP, I need to check what I need to do, I have never done it before

We added a lot of AEPs lately, you can look at some of them to get the hang of it. It's pretty straightforward.

@adrianmoisey
Copy link
Member

For the AEP, I need to check what I need to do, I have never done it before

It's similar to the KEP process for Kubernetes, but it's much more light weight. We are trying to ensure a high standard and also keep the standard similar to Kubernetes (ie: API review, feature gates, etc), but they aren't that hard to do, and as Omer suggested, take a look at the most recent ones.

They live in https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler 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. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants