-
Notifications
You must be signed in to change notification settings - Fork 144
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
The user can fail to write to a volume even if fsGroup is properly set in securityContext #835
Comments
@mpatlasov can you provide the csi driver logs on the node? kubelet should Delegate fsGroup to CSI Driver in https://kubernetes-csi.github.io/docs/support-fsgroup.html#delegate-fsgroup-to-csi-driver |
@andyzhangx , csi driver uses Delegate fsGroup correctly:
adding
However, the mount point is not writeable for the group:
I cannot see any workaround or solution to overcome this issue. Do you have any? |
If user sets `fsGroup: <gid>` in Pod's spec.securityContext, kubelet delegate fsGroup to CSI Driver, and NodeStageVolume() adds `gid=<gid>` to mount options. This might be not enough to make volume writable for the user: ``` $ kubectl exec fedora -- ls -ld /mnt/claim drwxr-xr-x. 2 root 1002 0 Sep 13 12:04 /mnt/claim $ kubectl exec fedora -- touch /mnt/claim/FILE touch: cannot touch '/mnt/claim/FILE': Permission denied ``` See kubernetes-csi#835
@andyzhangx I'd appreciate your feedback on #848 . It fixes the issue by setting file_mode and dir_mode mount options. If this approach is tolerable, I'll add unit-tests to the PR. Thanks! |
If user sets `fsGroup: <gid>` in Pod's spec.securityContext, kubelet delegate fsGroup to CSI Driver, and NodeStageVolume() adds `gid=<gid>` to mount options. This might be not enough to make volume writable for the user: ``` $ kubectl exec fedora -- ls -ld /mnt/claim drwxr-xr-x. 2 root 1002 0 Sep 13 12:04 /mnt/claim $ kubectl exec fedora -- touch /mnt/claim/FILE touch: cannot touch '/mnt/claim/FILE': Permission denied ``` See kubernetes-csi#835
…on must ensure RWX for the group If user sets `fsGroup: <gid>` in Pod's spec.securityContext, kubelet delegate fsGroup to CSI Driver, and NodeStageVolume() adds `gid=<gid>` to mount options. This might be not enough to make volume writable for the user: ``` $ kubectl exec fedora -- ls -ld /mnt/claim drwxr-xr-x. 2 root 1002 0 Sep 13 12:04 /mnt/claim $ kubectl exec fedora -- touch /mnt/claim/FILE touch: cannot touch '/mnt/claim/FILE': Permission denied ``` See kubernetes-csi#835
…RWX for the group If user sets `fsGroup: <gid>` in Pod's spec.securityContext, kubelet delegate fsGroup to CSI Driver, and NodeStageVolume() adds `gid=<gid>` to mount options. This might be not enough to make volume writable for the user: ``` $ kubectl exec fedora -- ls -ld /mnt/claim drwxr-xr-x. 2 root 1002 0 Sep 13 12:04 /mnt/claim $ kubectl exec fedora -- touch /mnt/claim/FILE touch: cannot touch '/mnt/claim/FILE': Permission denied ``` See kubernetes-csi#835
What happened:
Even if user explicitly requires the same fsGroup as runAsUser and runAsGroup for a Pod:
he/she will fail to write to the volume:
if StorageClass does not set uid/gid or dir_mode or noperm:
What you expected to happen:
If user requests the same fsGroup as runAsGroup in securityContext section of a pod definition, SMB CSI driver must construct mount options letting full access for that volume.
How to reproduce it:
Create StorageClass:
for a samba server from https://github.com/samba-in-kubernetes/samba-container .
Create a Pod requesting samba PV:
Verify that the volume is not write-able from the Pod:
Anything else we need to know?:
Environment:
CSI Driver version: Image manually built by
docker build ... -f ./cmd/smbplugin/Dockerfile .
from the top of upstream master branch (commit 4d10e97 of https://github.com/kubernetes-csi/csi-driver-smb.git)Kubernetes version (use
kubectl version
):The text was updated successfully, but these errors were encountered: