Skip to content

Commit 81407aa

Browse files
authored
Merge pull request #37621 from bertinatto/fsgroup-on-mount
Add blog post for FSGroup on mount
2 parents 2970da8 + 3a8065c commit 81407aa

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes 1.26: Support for Passing Pod fsGroup to CSI Drivers At Mount Time"
4+
date: 2022-12-23
5+
slug: kubernetes-12-06-fsgroup-on-mount
6+
---
7+
8+
**Authors:** Fabio Bertinatto (Red Hat), Hemant Kumar (Red Hat)
9+
10+
Delegation of `fsGroup` to CSI drivers was first introduced as alpha in Kubernetes 1.22,
11+
and graduated to beta in Kubernetes 1.25.
12+
For Kubernetes 1.26, we are happy to announce that this feature has graduated to
13+
General Availability (GA).
14+
15+
In this release, if you specify a `fsGroup` in the
16+
[security context](/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod),
17+
for a (Linux) Pod, all processes in the pod's containers are part of the additional group
18+
that you specified.
19+
20+
In previous Kubernetes releases, the kubelet would *always* apply the
21+
`fsGroup` ownership and permission changes to files in the volume according to the policy
22+
you specified in the Pod's `.spec.securityContext.fsGroupChangePolicy` field.
23+
24+
Starting with Kubernetes 1.26, CSI drivers have the option to apply the `fsGroup` settings during
25+
volume mount time, which frees the kubelet from changing the permissions of files and directories
26+
in those volumes.
27+
28+
## How does it work?
29+
30+
CSI drivers that support this feature should advertise the
31+
[`VOLUME_MOUNT_GROUP`](https://github.com/container-storage-interface/spec/blob/master/spec.md#nodegetcapabilities) node capability.
32+
33+
After recognizing this information, the kubelet passes the `fsGroup` information to
34+
the CSI driver during pod startup. This is done through the
35+
[`NodeStageVolumeRequest`](https://github.com/container-storage-interface/spec/blob/v1.7.0/spec.md#nodestagevolume) and
36+
[`NodePublishVolumeRequest`](https://github.com/container-storage-interface/spec/blob/v1.7.0/spec.md#nodepublishvolume)
37+
CSI calls.
38+
39+
Consequently, the CSI driver is expected to apply the `fsGroup` to the files in the volume using a
40+
_mount option_. As an example, [Azure File CSIDriver](https://github.com/kubernetes-sigs/azurefile-csi-driver) utilizes the `gid` mount option to map
41+
the `fsGroup` information to all the files in the volume.
42+
43+
It should be noted that in the example above the kubelet refrains from directly
44+
applying the permission changes into the files and directories in that volume files.
45+
Additionally, two policy definitions no longer have an effect: neither
46+
`.spec.fsGroupPolicy` for the CSIDriver object, nor
47+
`.spec.securityContext.fsGroupChangePolicy` for the Pod.
48+
49+
For more details about the inner workings of this feature, check out the
50+
[enhancement proposal](https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/2317-fsgroup-on-mount/)
51+
and the [CSI Driver `fsGroup` Support](https://kubernetes-csi.github.io/docs/support-fsgroup.html)
52+
in the CSI developer documentation.
53+
54+
## Why is it important?
55+
56+
Without this feature, applying the fsGroup information to files is not possible in certain storage environments.
57+
58+
For instance, Azure File does not support a concept of POSIX-style ownership and permissions
59+
of files. The CSI driver is only able to set the file permissions at the volume level.
60+
61+
## How do I use it?
62+
63+
This feature should be mostly transparent to users. If you maintain a CSI driver that should
64+
support this feature, read
65+
[CSI Driver `fsGroup` Support](https://kubernetes-csi.github.io/docs/support-fsgroup.html)
66+
for more information on how to support this feature in your CSI driver.
67+
68+
Existing CSI drivers that do not support this feature will continue to work as usual:
69+
they will not receive any `fsGroup` information from the kubelet. In addition to that,
70+
the kubelet will continue to perform the ownership and permissions changes to files
71+
for those volumes, according to the policies specified in `.spec.fsGroupPolicy` for the
72+
CSIDriver and `.spec.securityContext.fsGroupChangePolicy` for the relevant Pod.

0 commit comments

Comments
 (0)