Skip to content
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

KEP-3619: Fine-grained SupplementalGroups control #117842

Merged

Conversation

everpeace
Copy link
Contributor

@everpeace everpeace commented May 6, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Implements kubernetes/enhancements#3619

Special notes for your reviewer:

The actual policy enforcement will be implemented by container runtimes (cri-api implementations). Because most container runtimes (e.g. containerd) depend on https://github.com/kubernetes/cri-api, this PR should be merged before container runtimes implement actual policy enforcement. Please also see CRI API | Feature development.

My PR in containerd is already opened and in review: containerd/containerd#9737. It already got LGTM (containerd/containerd#9737 (review)) except for cri-api dependency, which will be updated once this PR gets merged and v1.31 alpha or beta version is released.

If you wanted to try running this feature, you can try it with kind easily: https://gist.github.com/everpeace/2ae0233cc91644ac8797cf192e40ba39

Does this PR introduce a user-facing change?

Support fine-grained supplemental groups policy (KEP-3619), which enables fine-grained control for supplementary groups in the first container processes. You can choose whether to include groups defined in the container image(/etc/groups) for the container's primary uid or not.

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/3619-supplemental-groups-policy

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 6, 2023
@k8s-ci-robot k8s-ci-robot added area/code-generation area/kubelet kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 6, 2023
@everpeace everpeace force-pushed the kep-3619-SupplementalGroupsPolicy branch 4 times, most recently from 04cc30c to 8d38468 Compare May 7, 2023 07:20
@everpeace everpeace force-pushed the kep-3619-SupplementalGroupsPolicy branch 2 times, most recently from 74b822e to 3052133 Compare May 7, 2023 12:04
@everpeace everpeace changed the title [WIP] KEP-3619: Fine-grained SupplementalGroups control KEP-3619: Fine-grained SupplementalGroups control May 7, 2023
@everpeace everpeace marked this pull request as ready for review May 8, 2023 10:07
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2023
@k8s-ci-robot k8s-ci-robot requested a review from andrewsykim May 8, 2023 10:07
Copy link
Contributor Author

@everpeace everpeace left a comment

Choose a reason for hiding this comment

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

Addressed comments for no need featuregate checks in validation logics. And rebased to the latest master.

pkg/apis/core/validation/validation.go Outdated Show resolved Hide resolved
pkg/apis/core/validation/validation.go Outdated Show resolved Hide resolved
@thockin
Copy link
Member

thockin commented May 23, 2024

/approve for API

Needs sig-node review, please

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 23, 2024
@mrunalp
Copy link
Contributor

mrunalp commented May 23, 2024

I will review for sig-node.

"$ref": "#/components/schemas/io.k8s.api.core.v1.ContainerUser"
}
],
"description": "User represents user identitiy information of the first process in the container"
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: identity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 5f0d761

@@ -2741,6 +2741,31 @@ type ContainerStatus struct {
// +optional
// +featureGate=RecursiveReadOnlyMounts
VolumeMounts []VolumeMountStatus
// User represents user identitiy information of the first process in the container
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: identity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 5f0d761

@mrunalp
Copy link
Contributor

mrunalp commented May 29, 2024

The node bits look fine. Only other nit I have is making the commits additive vs. fixing up earlier commits.
We can add e2es for this once the runtimes support this. Thanks!

@everpeace
Copy link
Contributor Author

everpeace commented May 29, 2024

The node bits look fine.

Thanks🙌👍! And, my typo was fixed.

Only other nit I have is making the commits additive vs. fixing up earlier commits.

I think squashing my commits into one would be nice. Are we ready to squash now??

We can add e2es for this once the runtimes support this. Thanks!

For container runtimes supporting this feature, we need to merge this PR first as defined in CRI API | Feature development. Thus, e2es will be added in another PR after containerd released the newer version which supports this. Am I right?

@everpeace

This comment was marked as off-topic.

@mrunalp
Copy link
Contributor

mrunalp commented May 29, 2024

Thus, e2es will be added in another PR after containerd released the newer version which supports this. Am I right?

Yes, that's right.

I think squashing my commits into one would be nice. Are we ready to squash now??

The PR looks ready to me.

@thockin
Copy link
Member

thockin commented May 29, 2024

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 29, 2024
@thockin
Copy link
Member

thockin commented May 29, 2024

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 29, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c42214bbbcc0a9c46c00a8fc6bed4b676bd28450

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: everpeace, thockin

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 merged commit 552fd7e into kubernetes:master May 29, 2024
15 of 16 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.31 milestone May 29, 2024
@everpeace everpeace deleted the kep-3619-SupplementalGroupsPolicy branch May 29, 2024 23:35
@everpeace
Copy link
Contributor Author

@thockin @mrunalp Thank you very very much for your review and patient nurturing🙇!

@thockin
Copy link
Member

thockin commented May 29, 2024 via email

harpreet9ja pushed a commit to harpreet9ja/kubernetes that referenced this pull request Jun 30, 2024
* Add `Linux{Sandbox,Container}SecurityContext.SupplementalGroupsPolicy` and `ContainerStatus.user` in cri-api

* Add `PodSecurityContext.SupplementalGroupsPolicy`, `ContainerStatus.User` and its featuregate

* Implement DropDisabledPodFields for PodSecurityContext.SupplementalGroupsPolicy and ContainerStatus.User fields

* Implement kubelet so to wire between SecurityContext.SupplementalGroupsPolicy/ContainerStatus.User and cri-api in kubelet

* Clarify `SupplementalGroupsPolicy` is an OS depdendent field.

* Make `ContainerStatus.User` is initially attached user identity to the first process in the ContainerStatus

It is because, the process identity can be dynamic if the initially attached identity
has enough privilege calling setuid/setgid/setgroups syscalls in Linux.

* Rewording suggestion applied

* Add TODO comment for updating SupplementalGroupsPolicy default value in v1.34

* Added validations for SupplementalGroupsPolicy and ContainerUser

* No need featuregate check in validation when adding new field with no default value

* fix typo: identitiy -> identity
YamasouA pushed a commit to YamasouA/kubernetes that referenced this pull request Jul 24, 2024
* Add `Linux{Sandbox,Container}SecurityContext.SupplementalGroupsPolicy` and `ContainerStatus.user` in cri-api

* Add `PodSecurityContext.SupplementalGroupsPolicy`, `ContainerStatus.User` and its featuregate

* Implement DropDisabledPodFields for PodSecurityContext.SupplementalGroupsPolicy and ContainerStatus.User fields

* Implement kubelet so to wire between SecurityContext.SupplementalGroupsPolicy/ContainerStatus.User and cri-api in kubelet

* Clarify `SupplementalGroupsPolicy` is an OS depdendent field.

* Make `ContainerStatus.User` is initially attached user identity to the first process in the ContainerStatus

It is because, the process identity can be dynamic if the initially attached identity
has enough privilege calling setuid/setgid/setgroups syscalls in Linux.

* Rewording suggestion applied

* Add TODO comment for updating SupplementalGroupsPolicy default value in v1.34

* Added validations for SupplementalGroupsPolicy and ContainerUser

* No need featuregate check in validation when adding new field with no default value

* fix typo: identitiy -> identity
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/feature Categorizes issue or PR as related to a new feature. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.