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.