kubernetes-csi / csi-driver-nfs

This driver allows Kubernetes to access NFS server on Linux node.
Apache License 2.0
870 stars 252 forks source link

Cannot use labels in `subDir` #791

Open mmelcot opened 1 week ago

mmelcot commented 1 week ago

What happened: When creating a StorageClass, if one use labels of a PVC or PV in the subDir, it is not correctely interpreted.

What you expected to happen: I expect the NFS CSI storage class to create a folder hierarchy in the NFS server, using the label foo from my pvc. Instead, I got something like:

          my_namespace
              ${pvc.metadata.labels.foo}
                     my_pvc_name

i.e. that the labels are not correctly interpreted.

How to reproduce it: Define a StorageClass in which you configured subDir with something like: subDir: ${pvc.metadata.namespace}/${pvc.metadata.labels.foo}/${pvc.metadata.name}

And then create a PVC with:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
  labels:
    foo: "bar"

Create a pod using that PVC, and check which folder hierarchy it creates in the NFS

Environment:

andyzhangx commented 1 week ago

only following metadata is supported per the doc: https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/docs/driver-parameters.md#subdir-parameter-supports-following-pvpvc-metadata-conversion

${pvc.metadata.name} ${pvc.metadata.namespace} ${pv.metadata.name}