Kubernetes NFS mount permissions

12/21/2020

I have a problem with access permissions for group when mounting the NFS folder to the K8s POD. When a file is created within the pod the permissions are read-only for the group on the NFS server.

(A) I have tried to set the security context on the pod:

securityContext: <br> runAsUser: 1000 <br> runAsGroup: 1000 <br> fsGroup: 1000

The id (1000) is the same as the group id on the NFS server.

(B) Also I tried with initContainer param:

initContainers: <br> name: test <br> image: imagename <br> command: ["/bin/chmod","-R","660", "/data"]

With this both case solutions the new created files have the following permissions which is not acceptable:

-rw-r--r-- 1 1000 1000 test.txt

I have succeeded to create files within a pod with the needed permissions:

-rw-rw-r-- 1 1000 1000 test.txt

Only if I create a user on the running pod and switch to it with the same ID on the NFS server.

-- lvadim01
kubernetes
linux
nfs
permissions

1 Answer

12/21/2020

I would recommend you to use one of the two below Method : Modify security context securityContext: runAsGroup: 65534 runAsUser: 65534 Method 2: Create an empty directory and mount it . This should solve - emptyDir: {} name: data mount it on to some volume /data

-- Sunjay Jeffrish
Source: StackOverflow