hpe-storage / csi-driver

A Container Storage Interface (CSI) driver from HPE
https://scod.hpedev.io
Apache License 2.0
61 stars 56 forks source link

Volume provisioning with multiple storage backends #417

Open lechugaletal opened 1 month ago

lechugaletal commented 1 month ago

I'm trying to find if there is a way to provision PVs from multiple storage backends given a StatefulSet that has a single StorageClass defined in its volumeClaimTemplates section.

Given a StatefulSet with a spec of spec.volumeClaimTemplates.storageClassName: test-sc (pointing to a single StorageClass), and a storageClass with an hypothetical spec like:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: test-sc
parameters:
  backends:
    - accessProtocol: fc1
      csi.storage.k8s.io/controller-expand-secret-name: hpe-backend1
      csi.storage.k8s.io/controller-expand-secret-namespace: hpe-storage
      csi.storage.k8s.io/fstype: ext4
    - accessProtocol: fc2
      csi.storage.k8s.io/controller-expand-secret-name: hpe-backend2
      csi.storage.k8s.io/controller-expand-secret-namespace: hpe-storage
      csi.storage.k8s.io/fstype: ext4
      imageFeatures: layering
      pool: rbd
provisioner: csi.hpe.com
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
  - key: csi.hpe.com/zone
    values:
    - fc1
    - fc2

Could it be possible to provision PVs from one backend or another depending on the zone or region in which the pod is scheduled?

Thank you very much for your help!

datamattsson commented 1 month ago

Hey! Thanks for reaching out. What you're trying to do can not be automatically performed unfortunately. It requires the CSI Topology feature to be enhanced further in the driver. We're not sure how such implementation would look but we would most likely add topology information to the backend Secret and allow multiple backends in one Secret.

However, since StatefulSet PVC names are predictable, you can have two StorageClasses (topology-fc1 and topology-fc2) and manually create the PVCs before creating the StatefulSet.