kubernetes-csi/csi-driver-nfs

Avoid creating subDir with storageclass like csi-driver-smb

Closed this issue · 3 comments

Is your feature request related to a problem?/Why is this needed
I would like to have the ability to create a storage class and PVCs that use the same folder, without needing to create a separate PV/PVC without a storage class for each app (we have a lot of apps).

Filesystem tree

folder1
folder2
folder3

instead of

folder1
folder2
folder3
pvc-xxxxxx
  folder1
  folder2
  folder3
pvc-xxxxxx
  folder1
  folder2
  folder3
pvc-xxxxxx
  folder1
  folder2
  folder3

Describe the solution you'd like in detail
A solution like csi-driver-smb.

With this storage class, when I create a PVC, it automatically generates the associated PV and allows me to bind directly to the folder inside the SMB mount without creating a separate folder with the PVC name.

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: apps-smb
provisioner: smb.csi.k8s.io
parameters:
  source: //nas.example.com/apps
  # magic is here I guess
  # https://github.com/kubernetes-csi/csi-driver-smb/blob/master/deploy/example/storageclass-smb.yaml#L10
  csi.storage.k8s.io/node-stage-secret-name: csi-driver-smb-vault
  csi.storage.k8s.io/node-stage-secret-namespace: csi-driver-smb
volumeBindingMode: Immediate
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1001
  - gid=1001
  - noperm
  - mfsymlinks
  - cache=strict
  - noserverino
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: apps-storage
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi # dummy value
  storageClassName: "apps-smb"

Describe alternatives you've considered
Running SMB instead.

Additional context

@M0NsTeRRR so you need to specify subDir parameter in your storage class

subDir | sub directory under nfs share |   | No | if sub directory does not exist, this driver would create a new one -- | -- | -- | -- | --

@M0NsTeRRR so you need to specify subDir parameter in your storage class
subDir | sub directory under nfs share | | No | if sub directory does not exist, this driver would create a new one -- | -- | -- | -- | --

Yes, I tried that, but unfortunately, it prevents me from binding the same folder twice, like folder1 across two PVCs (differents applications) whereas csi-driver-smb allows it.

I will retry and let you know, maybe I've missed something.

I retested it, and it worked! Not sure what I did wrong the first time to cause the error. Sorry for the noise.