...
The read-write permissions are not governed by the access-mode parameter, but by the settings used in the NFS configuration. Let's try to give examples in both cases.
Read-Only mode
The steps to follow in this case are:
- create a PVC (the created PVC will be in pending state, because the provisioner does not have write permissions);
- create a directory, inside the
<exported_path>, according to thepathPatternparameter (seevalues.yamlabove); - once the PVC is in bound state, it can be used.
Read-Write mode
The steps to follow in this case are:
- create a PVC: this will create a directory inside the
<exported_path>, according to thepathPatternparameter, and the corresponding PV; - use the newly created PVC.
Example
Let's try the following example, working in the nfs-test namespace. Once the provisioner is implemented, we create a PVC
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-claim
spec:
storageClassName: nfs-sc # Use the name of the SC created
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 5Mi |
The PVC will remain in the pending state until the folder is created within the <exported_path>, according to the pathPattern parameter. In our case, the folder name must be equal to <namespace>-<PVC_name>, that is nfs-test-test-claim.
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
$ k apply -f test-claim.yaml -n nfs-test
$ k get pvc -n nfs-test
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
test-claim Pending nfs-sc 60s
$ k get pvc -n nfs-test
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/test-claim Bound pvc-10663683-eece-46ca-b83d-53f88a1cabc9 5Mi ROX nfs-sc 4m3s |