Skip to content

Conversation

@toVersus
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR is taking over from #132627.

Adds the following checks based on the KEP description:

  • API server to reject Pod with PodLevelResources if Pod targets Windows OS.
  • kubelet to reject Pod with PodLevelResources on nodes other than Linux OS at admission phase.

Which issue(s) this PR is related to:

Fixes: #132582

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added validation to reject Pods using the `PodLevelResources` feature on Windows OS due to lack of support. The API server rejects Pods with Pod-level resources and a `Pod.spec.os.name` targeting Windows. Kubelet on nodes running Windows also rejects Pods with Pod-level resources at admission phase.

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. 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 Jul 18, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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
Copy link
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.

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. labels Jul 18, 2025
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Jul 18, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jul 18, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps Jul 18, 2025
@toVersus
Copy link
Contributor Author

/assign @tallclair @ndixita

@toVersus toVersus changed the title Reject windows in api server [PodLevelResources] Add validation for Windows OS Jul 18, 2025
Copy link
Contributor

@HirazawaUi HirazawaUi left a comment

Choose a reason for hiding this comment

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

I noticed that validatePodResources currently doesn't have a dedicated unit test. Given that it's complex enough, would you be willing to add one?

@toVersus toVersus force-pushed the reject-windows-in-api-server branch from 14f7dab to d81b37b Compare July 18, 2025 05:43
@toVersus
Copy link
Contributor Author

I noticed that validatePodResources currently doesn't have a dedicated unit test. Given that it's complex enough, would you be willing to add one?

Thanks for the suggestion! I've added a new unit test specifically for validatePodResources. Since unit tests for the functions called within validatePodResources already exist, I focused on adding basic test cases and ones focused on validatePodResources.

@toVersus toVersus force-pushed the reject-windows-in-api-server branch from d81b37b to 02399ed Compare July 18, 2025 06:55
@HirazawaUi
Copy link
Contributor

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ebd3624ab87caf0294ab174a86988fc9a6ae888a

if spec.Resources == nil {
return nil
}
resourcesFldPath := fldPath.Child("resources")
Copy link
Member

Choose a reason for hiding this comment

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

(no action item here, just documenting my thought process)

Normally when we change validation, we need to consider ratcheting validation to support n-1 version skew betwen api servers.

But in this case since it's alpha in 1.33 and the Pod.spec.resources field is immutable in 1.33, then this is a safe change to make. Objects created in 1.34 will have the tightened validation, and 1.33 api servers will still succeed validation with the looser validation.

annasong20 and others added 3 commits July 23, 2025 07:08
Reject Pod with PodLevelResources in spec if Pod targets Windows OS.
Reject pods with PodLevelResources running on Windows nodes
at kubelet admission phase
@toVersus toVersus force-pushed the reject-windows-in-api-server branch from fb3bafc to 88af8b6 Compare July 22, 2025 22:08
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot added area/code-generation kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jul 22, 2025
@k8s-triage-robot
Copy link

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.

@msau42
Copy link
Member

msau42 commented Jul 22, 2025

Approving API changes with one spelling nit.
/approve

// Do not include more detailed errors on the resources field value
// if the resources field may not be set on the target OS.
return field.ErrorList{
field.Forbidden(resourcesFldPath, "may not be set for a windows pod"),
Copy link
Member

Choose a reason for hiding this comment

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

Should "windows" be capitalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to keep it as is for consistency with other existing validation messages, which also use the term "windows pods."

@ndixita
Copy link
Contributor

ndixita commented Jul 23, 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 23, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6637be9307631e3bf273cb848215c330af3b530d

@dchen1107
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
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

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 23, 2025
@k8s-ci-robot k8s-ci-robot merged commit 9adc49f into kubernetes:master Jul 24, 2025
16 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 Triage to Done in SIG Apps Jul 24, 2025
@toVersus toVersus deleted the reject-windows-in-api-server branch July 24, 2025 03:15
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/code-generation area/kubelet 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[PodLevelResources] Validation for Windows OS

10 participants