Search code examples
kubernetesminiopersistent-volumes

how to define volumeHandle to create persistent volume managed by csi directpv?


I am trying to create a PV with csi drivers, it does not allow to create, since there is no mandatory attribute volumeHandle. The documentation says that this field is equal to volume_id, and where to get this volume id?

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/provisioned-by: directpv-min-io 
    volume.kubernetes.io/provisioner-deletion-secret-name: ""
    volume.kubernetes.io/provisioner-deletion-secret-namespace: ""
  name: pvc-minio-1
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 1000Gi
  csi:
    driver: directpv-min-io
    fsType: xfs
  persistentVolumeReclaimPolicy: Delete
  storageClassName: directpv-min-io

Solution

  • In my understanding, the volumeHandle (VolumeID) can be anything, as long as it is unique for the resource behind it (e.g. a folder in a share on an NFS server). That is why the doc of the NFS CSI driver recommends a certain structure for the volumeHandle string to ensure a unique value for each server+share+folder combination.

    I do not have experience with the DirectPV driver but the same principle applies there.