Skip to content

feat: add optional LimitRange to Profiles - #514

Open
Bhup-GitHUB wants to merge 5 commits into
kubeflow:mainfrom
Bhup-GitHUB:feat/profile-limitrange-21
Open

Bhup-GitHUB wants to merge 5 commits into
kubeflow:mainfrom
Bhup-GitHUB:feat/profile-limitrange-21

Conversation

@Bhup-GitHUB

Copy link
Copy Markdown

Closes #21

Problem
A Profile can set a ResourceQuota for its namespace, but not a LimitRange. When the quota covers requests/limits, every pod that omits resources is rejected, and admins have to manage a LimitRange in each profile namespace by hand.

Approach

  • Add an optional spec.limitRangeSpec (*corev1.LimitRangeSpec) to Profile v1 and v1beta1. The field is opt-in, so existing Profiles are unchanged.
  • When the field is set, the profile controller creates or updates a kf-limit-range LimitRange in the profile namespace, owned by the Profile. An existing unowned kf-limit-range is adopted.
  • When the field is unset or has no limits, the LimitRange is deleted only if the Profile owns it, so hand-made LimitRanges are never removed.
  • Specs are compared with semantic equality, so equivalent quantities (1 vs 1000m) don't cause updates.
  • Unit tests cover create, update, adopt, owned-only delete and semantic equality. The integration profile now sets a LimitRange, and validate checks that a pod without resources is admitted with default requests.

Before
before-21.png

After
after-21.png

cc @juliusvonkohout

Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
@google-oss-prow google-oss-prow Bot added the area/profiles area - related to profile-controller label Nov 19, 2026

@juliusvonkohout juliusvonkohout left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All variable names must be long and expressive. "r" or "err" or "ctx" or "spec" or "t" violate that.

Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
@google-oss-prow

Copy link
Copy Markdown

[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 ask for approval from juliusvonkohout. For more information see the Kubernetes Code Review Process.

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

Details 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

@Bhup-GitHUB

Copy link
Copy Markdown
Author

@juliusvonkohout Thanks for the review. I renamed the short variables in the new LimitRange code and its tests to descriptive names in e27d6a0 (for example reconciler, requestContext, existingLimitRange, getError, limitRangeError). I left the existing ctx, r and logger in Reconcile unchanged to keep the diff focused, but I can rename those too if you prefer. PTAL.

@Bhup-GitHUB

Copy link
Copy Markdown
Author

@juliusvonkohout I renamed the short variables as you asked. Could you take another look when you have time?

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

Labels

area/profiles area - related to profile-controller size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Profile] Allow containers/pods without resources

2 participants