Skip to content

[PodLevelResources] Update Downward API defaulting for resource limits#132605

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
toVersus:feat/downward-api-plresources
Jul 24, 2025
Merged

[PodLevelResources] Update Downward API defaulting for resource limits#132605
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
toVersus:feat/downward-api-plresources

Conversation

@toVersus
Copy link
Copy Markdown
Contributor

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.

  • 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.

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?

The fallback behavior of the Downward API's `resourceFieldRef` field has been updated to account for pod-level resources: if container-level limits are not set, pod-level limits are now used before falling back to node allocatable resources.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

[KEP]: https://github.com/kubernetes/enhancements/issues/2837

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 29, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

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 /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.

Details

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet area/test kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. labels Jun 29, 2025
@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 29, 2025
@toVersus
Copy link
Copy Markdown
Contributor Author

/cc @ndixita

@k8s-ci-robot k8s-ci-robot requested a review from ndixita June 29, 2025 09:43
@k8s-triage-robot
Copy link
Copy Markdown

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.

Comment thread pkg/kubelet/kubelet_resources.go
@ndixita
Copy link
Copy Markdown
Contributor

ndixita commented Jun 29, 2025

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 29, 2025
@toVersus toVersus force-pushed the feat/downward-api-plresources branch from adcfa0d to bedd1ef Compare June 30, 2025 00:33
@toVersus
Copy link
Copy Markdown
Contributor Author

/assign @tallclair
If you have the capacity, I’d appreciate it if you could take a look at this as well.

Comment thread test/e2e/common/node/downwardapi.go
@toVersus toVersus force-pushed the feat/downward-api-plresources branch from 64bb683 to 98c19a8 Compare July 23, 2025 22:43
@toVersus
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-node-kubelet-serial-podresources

Comment thread pkg/kubelet/kubelet_resources.go Outdated
@ndixita
Copy link
Copy Markdown
Contributor

ndixita commented Jul 23, 2025

@kubernetes/sig-node-pr-reviews - can someone PTAL

@dchen1107
Copy link
Copy Markdown
Member

I did a quick review on the PR and looks good to me.

@ndixita I am approving this, but leave you to give the last lgtm for merge.

/approve

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]>
@toVersus toVersus force-pushed the feat/downward-api-plresources branch from 98c19a8 to a82187c Compare July 23, 2025 23:15
@toVersus
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-node-kubelet-serial-podresources

@msau42
Copy link
Copy Markdown
Member

msau42 commented Jul 24, 2025

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dchen1107, msau42, toVersus

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2025
@ndixita
Copy link
Copy Markdown
Contributor

ndixita commented Jul 24, 2025

/lgtm

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

LGTM label has been added.

DetailsGit tree hash: 7a3a2a912510d0d204c38143ee01d9deedd8c902

@k8s-ci-robot k8s-ci-robot merged commit bd7fb73 into kubernetes:master Jul 24, 2025
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone Jul 24, 2025
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in SIG Node: Pod Level Resources Jul 24, 2025
@github-project-automation github-project-automation Bot moved this from Needs Reviewer to Done in SIG Node: code and documentation PRs Jul 24, 2025
@github-project-automation github-project-automation Bot moved this from Archive-it to Done in SIG Node CI/Test Board Jul 24, 2025
@toVersus toVersus deleted the feat/downward-api-plresources branch July 24, 2025 23:54

})

var _ = SIGDescribe("Downward API", feature.PodLevelResources, func() {
Copy link
Copy Markdown
Contributor

@HirazawaUi HirazawaUi Jul 26, 2025

Choose a reason for hiding this comment

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

It appears that we did not properly execute this test case in this PR.

PodLevelResources is a feature gate in the alpha stage. We should follow Option 1 mentioned in this email (https://groups.google.com/a/kubernetes.io/g/dev/c/uVga86nJDuI/m/gVujvOCnDwAJ) to correctly add the label for the test case, or manually trigger the dedicated e2e test job for the PodLevelResources feature (if we have already added one). Otherwise, it will be skipped during e2e test execution, Additionally, if some test job matches all features, it will execute this test case erroneously.

This e2e test case currently fails, and a related issue has been opened:
#133232

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please disregard this comment - it has already been discussed in PR #133220.

@liggitt liggitt moved this to API review completed, 1.34 in API Reviews Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Status: API review completed, 1.34
Archived in project

Development

Successfully merging this pull request may close these issues.

[PodLevelResources] Update Downward API defaulting logic for resource.limits

10 participants