Skip to content

Commit d0cdbb5

Browse files
authored
chore(docs): FilePermissions cas config user documentation (#128)
* This commit does the following changes - Add FilePermissions cas config user documentation - Add FilePermission key sample in StorageClass - Update non-root usage instructions Signed-off-by: Niladri Halder <niladri.halder@mayadata.io>
1 parent 41672bd commit d0cdbb5

File tree

4 files changed

+99
-40
lines changed

4 files changed

+99
-40
lines changed

deploy/kubectl/busybox-openebs-rwx.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ metadata:
55
name: openebs-rwx-pvc
66
#annotaions:
77
# cas.openebs.io/config: |
8-
# FilePermissions can be used to modify the owner, group
9-
# and file modes of the shared NFS filesystem.
8+
# FilePermissions defines the file ownership and mode specifications
9+
# for the NFS server's shared filesystem volume.
10+
# File permission changes are applied recursively if the root of the
11+
# volume's filesystem does not match the specified value.
1012
# - name: FilePermissions
1113
# data:
1214
# UID: "1000"

deploy/kubectl/openebs-nfs-provisioner.yaml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,27 +202,39 @@ metadata:
202202
value: "kernel"
203203
- name: BackendStorageClass
204204
value: "openebs-hostpath"
205-
# NFSServerResourceRequests defines the resource requests for NFS Server
205+
# NFSServerResourceRequests defines the resource requests for NFS Server
206206
#- name: NFSServerResourceRequests
207207
# value: |-
208208
# memory: 50Mi
209209
# cpu: 50m
210-
# NFSServerResourceLimits defines the resource limits for NFS Server
210+
# NFSServerResourceLimits defines the resource limits for NFS Server
211211
#- name: NFSServerResourceLimits
212212
# value: |-
213213
# memory: 100Mi
214214
# cpu: 100m
215-
# LeaseTime defines the renewl period(in seconds) for client state
215+
# LeaseTime defines the renewal period(in seconds) for client state
216216
#- name: LeaseTime
217217
# value: 30
218-
# GraceTime defines the recovery period(in seconds) to reclaim locks
218+
# GraceTime defines the recovery period(in seconds) to reclaim locks
219219
#- name: GraceTime
220220
# value: 30
221-
# FSGID defines the group permissions of NFS Volume. If it is set
222-
# then non-root applications should add FSGID value under pod
223-
# Suplemental groups.
224-
# The FSGID config key is being deprecated. Please use the
225-
# FilePermissions config key on the PersistentVolumeClaim instead.
221+
# FilePermissions defines the file ownership and mode specifications
222+
# for the NFS server's shared filesystem volume.
223+
# File permission changes are applied recursively if the root of the
224+
# volume's filesystem does not match the specified value.
225+
# Volume-specific file permission configuration can be specified by
226+
# using the FilePermissions config key in the PVC YAML, instead of
227+
# the StorageClass's.
228+
#- name: FilePermissions
229+
# data:
230+
# UID: "1000"
231+
# GID: "2000"
232+
# mode: "0744"
233+
# FSGID defines the group permissions of NFS Volume. If it is set
234+
# then non-root applications should add FSGID value under pod
235+
# Suplemental groups.
236+
# The FSGID config key is being deprecated. Please use the
237+
# FilePermissions config key instead.
226238
#- name: FSGID
227239
# value: "120"
228240
provisioner: openebs.io/nfsrwx

docs/troubleshooting/non-root-application-accesing-nfs-volume.md

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,31 @@ To support above use cases OpenEBS NFS Provisioner provides an option to configu
1313

1414
Non-root applications can consume NFS volume by following two steps:
1515

16-
- Create a StorageClass by specifying appropriate permissions under FSGID.
17-
Volumes provisioned by using below storage class will have permissions set to 120.
18-
```yaml
19-
#Sample storage classes with OpenEBS LVM-LocalPV
20-
apiVersion: storage.k8s.io/v1
21-
kind: StorageClass
22-
metadata:
23-
name: openebs-non-root-rwx
24-
annotations:
25-
openebs.io/cas-type: nfsrwx
26-
cas.openebs.io/config: |
27-
- name: NFSServerType
28-
value: "kernel"
29-
- name: BackendStorageClass
30-
value: "openebs-lvm-localpv"
31-
- name: FSGID
32-
value: "120"
33-
provisioner: openebs.io/nfsrwx
34-
reclaimPolicy: Delete
35-
```
16+
- Create a PersistentVolumeClaim by specifying appropriate permissions under the FilePermissions config key.
17+
The volumes provisioned for this PVC will have its group-owner set to 120, and its SetGID bit enabled ([read more](../tutorial/file-permissions.md)).
3618

37-
- Create a persistent volume claim with storage class referring to above example
19+
Sample PersistentVolumeClaim:
3820
```yaml
3921
kind: PersistentVolumeClaim
4022
apiVersion: v1
4123
metadata:
4224
name: nfs-pvc
25+
annotations:
26+
cas.openebs.io/config: |
27+
- name: FilePermissions
28+
data:
29+
GID: "120"
30+
mode: "g+s"
4331
spec:
44-
storageClassName: openebs-non-root-rwx
32+
storageClassName: openebs-kernel-nfs
4533
accessModes:
4634
- ReadWriteMany
4735
resources:
4836
requests:
4937
storage: 5G
5038
```
5139
52-
53-
- Now create an application by specifying `FSGID` value(i.e 120) under supplemental groups.
40+
- Now create an application by specifying the group ID value(i.e 120) under supplemental groups.
5441
When supplemental groups are specified corresponding user will be part of the same group
5542
and it makes volume accessible.
5643
```yaml
@@ -81,9 +68,6 @@ spec:
8168
claimName: nfs-pvc
8269
```
8370
84-
**Note**: Above NFS volume is deployed on OpenEBS LVM-Local PV.
85-
86-
8771
8872
### How to debug permission denied error?
8973
@@ -104,5 +88,3 @@ Following are the steps to find permissions configured on backend volume:
10488
Modify: 2021-07-09 11:23:41.933968717 +0000
10589
Change: 2021-07-09 11:23:41.933968717 +0000
10690
```
107-
108-
- If backend storage is an offering from CSI, check whether [fsGroupPolicy](https://kubernetes-csi.github.io/docs/support-fsgroup.html#csi-driver-fsgroup-support) is populated with an appropriate value.

docs/tutorial/file-permissions.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# How to set File Permissions for the shared filesystem
2+
3+
You can use the 'FilePermissions' key in the `cas.openebs.io/config` PersistentVolumeClaim annotation to modify the owner, group and file modes of the shared NFS filesystem.
4+
5+
The file permission changes are handled before the NFS server initializes.
6+
7+
The `chown` and `chmod` commands are run with the `--recursive` flag.<br>
8+
**NOTE:** The commands are run only if the existing values for the owner, the group or the file mode of the root of the shared directory do not match with the requested values. This is similar to the Kubernetes [fsGroupChangePolicy's "OnRootMismatch"](https://kubernetes.io/blog/2020/12/14/kubernetes-release-1.20-fsgroupchangepolicy-fsgrouppolicy/#allow-users-to-skip-recursive-permission-changes-on-mount).
9+
10+
Declare ownership and file mode change specfications using the UID, GID and mode keys (sample PersistentVolumeClaim below):<br>
11+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**UID:** This is the owner's user ID. Only valid UIDs are usable.<br>
12+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**GID:** This is the group ID of the owning group. Only valid GIDs are usable.<br>
13+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**mode:** Use this to specify the filesystem permission modes. Both octal and alphabet inputs are accepted. E.g. "0755", "g+rw".<br><br>
14+
All of the keys are optional.
15+
```yaml
16+
kind: PersistentVolumeClaim
17+
apiVersion: v1
18+
metadata:
19+
name: secure-vol
20+
annotations:
21+
cas.openebs.io/config: |
22+
- name: FilePermissions
23+
data:
24+
UID: "1000"
25+
GID: "2000"
26+
mode: "0744"
27+
spec:
28+
storageClassName: openebs-kernel-nfs
29+
accessModes:
30+
- ReadWriteMany
31+
resources:
32+
requests:
33+
storage: 10Gi
34+
```
35+
>**Note:** The FilePermissions config may be used with the `cas.openebs.io/config` StorageClass annotation key as well. If the config option is present on both the StorageClass and the PersistentVolumeClaim, the PersistentVolumeClaim config takes precedence.
36+
37+
## FSGID/fsGroup
38+
39+
The 'FSGID' config key (StorageClass annotations) is **being deprecated and will be removed in future releases**. At present, the FSGID config can be used, but it cannot be used along with FilePermission data keys 'GID' and/or 'mode'.
40+
41+
You can use the FilePermissions data values to change the group ownership and set a SetGID bit. This will result in changes similar to setting the fsGroup key in the NFS server Pod's securityContext (same as the previously-used FSGID `cas.openebs.io/config` key).
42+
43+
The following FilePermissions data values will result in a similar effect in volume permissions as setting fsGroup as '2000' with fsGroupChangePolicy as 'OnRootMismatch'.
44+
45+
```yaml
46+
kind: PersistentVolumeClaim
47+
apiVersion: v1
48+
metadata:
49+
name: secure-vol
50+
annotations:
51+
cas.openebs.io/config: |
52+
- name: FilePermissions
53+
data:
54+
GID: "2000"
55+
mode: "g+s"
56+
spec:
57+
storageClassName: openebs-kernel-nfs
58+
accessModes:
59+
- ReadWriteMany
60+
resources:
61+
requests:
62+
storage: 10Gi
63+
```

0 commit comments

Comments
 (0)