It seems the default provisioner in the StorageClass does not honour the mountOptions values. I tried to mount a block storage setting dir and file mode to 0777 and they were mounted with root only permissions. I need to change write permission because my containers run nginx which runs as root www-data. A workaround is to manually change the directory permission via chmod (either when the container starts with the command + args directives or directly logging in into the container).
Here’s my StorageClass and the PersistentVolumeClaims:
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: storage-rw mountOptions: - dir_mode=0777 - file_mode=0777 provisioner: dobs.csi.digitalocean.com --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: backend spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Ti storageClassName: storage-rw ---
Note: in azure aks with a storage account paired to the kubernetes shadow resource group and a similar configuration (changing only
StorageClass.provisioner: kubernetes.io/azure-file and
PersistentVolumeClaim.spec.accessModes: ReadWriteMany) allows me to create dynamic volumes with the correct file permissions.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!