ceph / ceph-csi

CSI driver for Ceph
Apache License 2.0
1.2k stars 528 forks source link

Feature Request: Automatic Directory Creation for Specified Path in PVs #4567

Closed christophenoel closed 2 months ago

christophenoel commented 2 months ago

Description:

Currently, when defining a PersistentVolume (PV) using the CephCSI driver, operator need to manually create the specified directory path on the CephFS file system before mounting the PV. If the directory does not exist, mounting the PV fails with an error stating that the path does not exist.

Here is an example of a PV configuration where the path needs to be pre-created:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: ceph-pv6
spec:
  capacity:
    storage: 1Gi
  storageClassName: csi-cephfs-sc
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Delete
  cephfs:
    path: /volumes/default-group/test6
    user: kubernetes
    secretRef:
      name: csi-fs-secret

Requested Feature:

It would be beneficial if the CephCSI driver could support automatic creation of the specified path if it does not already exist. This feature would allow users to specify any path in the PV configuration, and the driver would ensure the path is created on the CephFS before attempting to mount the volume.

Benefits:

Kind regards,

Christophe

Madhu-1 commented 2 months ago

@christophenoel The above is not a CSI PV it's an intree PV which is deprecated and removed. we dont create or delete any directories cephcsi uses subvolume concepts.

christophenoel commented 2 months ago

Ok, I did not understand what in-tree PV meant, now clear :)

Madhu-1 commented 2 months ago

@christophenoel closing now as its not possible, feel free to reopen if any further discussion is required.

nixpanic commented 2 months ago

@christophenoel you can write a Volume Populator which does this for you. Have a look at https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources for details.

One example is KubeVirt/CDI that downloads a VM image onto a PVC before an application pod can use it.