-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Add blog post for FSGroup on mount #37621
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,72 @@ | ||||||
--- | ||||||
layout: blog | ||||||
title: "Kubernetes 1.26: Support for Passing Pod fsGroup to CSI Drivers At Mount Time" | ||||||
date: 2022-12-23 | ||||||
slug: kubernetes-12-06-fsgroup-on-mount | ||||||
--- | ||||||
|
||||||
**Authors:** Fabio Bertinatto (Red Hat), Hemant Kumar (Red Hat) | ||||||
|
||||||
Delegation of `fsGroup` to CSI drivers was first introduced as alpha in Kubernetes 1.22, | ||||||
and graduated to beta in Kubernetes 1.25. | ||||||
For Kubernetes 1.26, we are happy to announce that this feature has graduated to | ||||||
General Availability (GA). | ||||||
|
||||||
In this release, if you specify a `fsGroup` in the | ||||||
[security context](/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod), | ||||||
for a (Linux) Pod, all processes in the pod's containers are part of the additional group | ||||||
that you specified. | ||||||
|
||||||
In previous Kubernetes releases, the kubelet would *always* apply the | ||||||
`fsGroup` ownership and permission changes to files in the volume according to the policy | ||||||
you specified in the Pod's `.spec.securityContext.fsGroupChangePolicy` field. | ||||||
|
||||||
Starting with Kubernetes 1.26, CSI drivers have the option to apply the `fsGroup` settings during | ||||||
volume mount time, which frees the kubelet from changing the permissions of files and directories | ||||||
in those volumes. | ||||||
|
||||||
## How does it work? | ||||||
|
||||||
CSI drivers that support this feature should advertise the | ||||||
[`VOLUME_MOUNT_GROUP`](https://github.com/container-storage-interface/spec/blob/master/spec.md#nodegetcapabilities) node capability. | ||||||
|
||||||
After recognizing this information, the kubelet passes the `fsGroup` information to | ||||||
the CSI driver during pod startup. This is done through the | ||||||
[`NodeStageVolumeRequest`](https://github.com/container-storage-interface/spec/blob/v1.7.0/spec.md#nodestagevolume) and | ||||||
[`NodePublishVolumeRequest`](https://github.com/container-storage-interface/spec/blob/v1.7.0/spec.md#nodepublishvolume) | ||||||
CSI calls. | ||||||
|
||||||
Consequently, the CSI driver is expected to apply the `fsGroup` to the files in the volume using a | ||||||
_mount option_. As an example, [Azure File CSIDriver](https://github.com/kubernetes-sigs/azurefile-csi-driver) utilizes the `gid` mount option to map | ||||||
the `fsGroup` information to all the files in the volume. | ||||||
|
||||||
It should be noted that in the example above the kubelet refrains from directly | ||||||
applying the permission changes into the files and directories in that volume files. | ||||||
Additionally, two policy definitions no longer have an effect: neither | ||||||
`.spec.fsGroupPolicy` for the CSIDriver object, nor | ||||||
`.spec.securityContext.fsGroupChangePolicy` for the Pod. | ||||||
|
||||||
For more details about the inner workings of this feature, check out the | ||||||
[enhancement proposal](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/2317-fsgroup-on-mount/) | ||||||
and the [CSI Driver `fsGroup` Support](https://kubernetes-csi.github.io/docs/support-fsgroup.html) | ||||||
in the CSI developer documentation. | ||||||
|
||||||
## Why is it important? | ||||||
|
||||||
Without this feature, applying the fsGroup information to files is not possible in certain storage environments. | ||||||
|
||||||
For instance, Azure File does not support a concept of POSIX-style ownership and permissions | ||||||
of files. The CSI driver is only able to set the file permissions at the volume level. | ||||||
|
||||||
## How do I use it? | ||||||
|
||||||
This feature should be mostly transparent to users. If you maintain a CSI driver that should | ||||||
support this feature, read | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “should support” looks idiomatic to me. |
||||||
[CSI Driver `fsGroup` Support](https://kubernetes-csi.github.io/docs/support-fsgroup.html) | ||||||
for more information on how to support this feature in your CSI driver. | ||||||
|
||||||
Existing CSI drivers that do not support this feature will continue to work as usual: | ||||||
they will not receive any `fsGroup` information from the kubelet. In addition to that, | ||||||
the kubelet will continue to perform the ownership and permissions changes to files | ||||||
for those volumes, according to the policies specified in `.spec.fsGroupPolicy` for the | ||||||
CSIDriver and `.spec.securityContext.fsGroupChangePolicy` for the relevant Pod. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.
As an addition, if all CSI drivers don't support this, do we want to link to a supported list?
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.
CSI drivers are third party software. Unless https://landscape.cncf.io/ covers them, there probably isn't any definitive list.