If you have an existing persistent storage file volume in your vCenter Server environment, use static provisioning with vSphere Container Storage Plug-in to make the storage instance available to your native Kubernetes cluster.

vSphere Container Storage Plug-in supports only vSAN file service volumes that are created with a hard quota limit. File service volumes that do not have a hard quota limit are not supported.

Procedure

  • Define a PVC and a PV.
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: static-file-share-pv-name
      annotations:
        pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
      labels:
        "static-pv-label-key": "static-pv-label-value"
    spec:
      capacity:
        storage: 1Gi
      accessModes:
        - ReadWriteMany
      persistentVolumeReclaimPolicy: Retain
      csi:
        driver: "csi.vsphere.vmware.com"
        volumeAttributes:
          type: "vSphere CNS File Volume"
        "volumeHandle": "file:236b3e6b-cfb0-4b73-a271-2591b2f31b4c"
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: static-file-share-pvc-name
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 1Gi
      selector:
        matchLabels:
          static-pv-label-key: static-pv-label-value
      storageClassName: ""
    • The labels key-value pair static-pv-label-key: static-pv-label-value used in PV metadata and PVC selector aid in matching the PVC to the PV during static provisioning.
    • Ensure to retain the file: prefix of the vSAN file share while filling up the volumeHandle field in the PV specification.
    Note: For file volumes, CNS supports multiple PVs that refer to the same file-share volume.