-
Notifications
You must be signed in to change notification settings - Fork 40.9k
[PodLevelResources] Update Downward API defaulting for resource limits #132605
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
base: master
Are you sure you want to change the base?
Conversation
Hi @toVersus. 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 Once the patch is verified, the new status will be reflected by the 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: toVersus 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 |
/cc @ndixita |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
@@ -42,13 +45,24 @@ func (kl *Kubelet) defaultPodLimitsForDownwardAPI(pod *v1.Pod, container *v1.Con | |||
return nil, nil, fmt.Errorf("failed to find node object, expected a node") | |||
} | |||
allocatable := node.Status.Allocatable | |||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.PodLevelResources) && resourcehelper.IsPodLevelLimitsSet(pod) { | |||
allocatable = allocatable.DeepCopy() | |||
for _, resource := range []corev1.ResourceName{corev1.ResourceCPU, corev1.ResourceMemory, corev1.ResourceEphemeralStorage} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - only cpu, memory and huge pages are supported at pod-level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This slice contains resources supported by the Downward API, so I added a check to verify whether each resource is also supported by Pod Level Resources.
/triage accepted |
Currently, when container-level resource limits were not specified and the Downward API was used to set environment variables referencing them, the node's allocatable resources were used as the fallback. With the introduction of the Pod Level Resources feature, this behavior is updated: if container-level resource limits are not specified, the Downward API now uses the pod-level resource limits instead. If neither container-level nor pod-level resource limits are specified, the behavior remains unchanged. It falls back to the node's allocatable resources. Signed-off-by: Tsubasa Nagasawa <[email protected]>
adcfa0d
to
bedd1ef
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
Using the Downward API's resourceFieldRef, you can inject values specified in
resources.limits
, such as CPU, memory, or ephemeral storage into environment variables. Currently, when container-level resource limits were not specified and the Downward API was used to set environment variables referencing them, the node's allocatable resources were used as the fallback. With the introduction of the Pod Level Resources feature, this behavior should be updated.Which issue(s) this PR is related to:
Fixes: #132603
KEP: kubernetes/enhancements#2837
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: