vSphere Container Storage Plug-in supports dynamic volume provisioning for block volumes. When you use the dynamic volume provisioning, you can create storage volumes on demand in native Kubernetes clusters.

When you provision volumes dynamically, consider the following items:
  • Dynamic volume provisioning allows you to create storage volumes on demand.
  • Without dynamic volume provisioning, cluster administrators have to manually make calls to their cloud or storage provider to create new storage volumes, and then create PersistentVolume objects to represent them in Kubernetes.
  • With dynamic volume provisioning, cluster administrators do not need to pre-provision backing storage. Instead, the dynamic provisioning automatically provisions storage when it is requested by users.
  • The implementation of dynamic volume provisioning is based on the API object StorageClass from the API group storage.k8s.io.
  • A cluster administrator can define as many StorageClass objects as required. Each StorageClass can specify a volume plug-in provisioner that provisions a volume, and a set of parameters.
  • A cluster administrator can define and expose multiple types of storage within a cluster by using custom set of parameters. Types of storage can be from the same or different storage systems.
For more information on provisioning volumes using topology and use of the WaitForFirstConsumer volumeBinding mode with dynamic volume provisioning, see Topology-Aware Volume Provisioning.
Note: Support for volume topology is present only in Vanilla Kubernetes for single-access (RWO) file system based volume.
You can provision a PersistentVolume dynamically on a native Kubernetes cluster by using the following steps.


  1. Define a Storage Class.
    kind: StorageClass
      apiVersion: storage.k8s.io/v1
        name: example-vanilla-block-sc
          storageclass.kubernetes.io/is-default-class: "true"
      provisioner: csi.vsphere.vmware.com
        storagepolicyname: "vSAN Default Storage Policy"  #Optional Parameter
      # datastoreurl: "ds:///vmfs/volumes/vsan:52cdfa80721ff516-ea1e993113acfc77/" #Optional Parameter
      # csi.storage.k8s.io/fstype: "ext4" #Optional Parameter
  2. Import this StorageClass into the native Kubernetes cluster.
    kubectl create -f example-sc.yaml
  3. Define a PersistentVolumeClaim request.
    apiVersion: v1
    kind: PersistentVolumeClaim
      name: example-vanilla-rwo-pvc
        - ReadWriteOnce
          storage: 5Gi
      storageClassName: example-vanilla-rwo-filesystem-sc
  4. Import the PersistentVolumeClaim into the Vanila Kubernetes cluster.
    kubectl create -f example-pvc.yaml
  5. Verify that the PersistentVolumeClaim has been created and has a PersistentVolume attached to it.
     $ kubectl describe pvc example-vanilla-rwo-pvc
          Name:          example-vanilla-rwo-pvc
          Namespace:     default
          StorageClass:  example-vanilla-rwo-filesystem-sc
          Status:        Bound
          Volume:        pvc-7ed39d8e-7896-11ea-a119-005056983fec
          Labels:        <none>
          Annotations:   pv.kubernetes.io/bind-completed: yes
                         pv.kubernetes.io/bound-by-controller: yes
                         volume.beta.kubernetes.io/storage-provisioner: csi.vsphere.vmware.com
          Finalizers:    [kubernetes.io/pvc-protection]
          Capacity:      5Gi
          Access Modes:  RWO
          VolumeMode:    Filesystem
          Mounted By:    <none>
            Type    Reason                 Age                From                                                                                                 Message
            ----    ------                 ----               ----                                                                                                 -------
            Normal  Provisioning           50s                csi.vsphere.vmware.com_vsphere-csi-controller-7777666589-jpnqh_798e6967-2ce1-486f-9c21-43d9dea709ae  External provisioner is provisioning volume for claim "default/example-vanilla-block-pvc"
            Normal  ExternalProvisioning   20s (x3 over 50s)  persistentvolume-controller                                                                          waiting for a volume to be created, either by external provisioner "csi.vsphere.vmware.com" or manually created by system administrator
            Normal  ProvisioningSucceeded  8s                 csi.vsphere.vmware.com_vsphere-csi-controller-7777666589-jpnqh_798e6967-2ce1-486f-9c21-43d9dea709ae  Successfully provisioned volume pvc-7ed39d8e-7896-11ea-a119-005056983fec
    When successfully created, the Status section shows Bound and the Volume field is populated.

    A PersistentVolume is automatically created, and is bound to this PersistentVolumeClaim.

    In this example, RWO access mode indicates that the volume is created on a vSphere virtual disk (First Class Disk).

  6. Verify that PersistentVolume has been successfully created for the PersistentVolumeClaim.
    $ kubectl describe pv pvc-7ed39d8e-7896-11ea-a119-005056983fec
          Name:            pvc-7ed39d8e-7896-11ea-a119-005056983fec
          Labels:          <none>
          Annotations:     pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
          Finalizers:      [kubernetes.io/pv-protection]
          StorageClass:    example-vanilla-rwo-filesystem-sc
          Status:          Bound
          Claim:           default/example-vanilla-rwo-pvc
          Reclaim Policy:  Delete
          Access Modes:    RWO
          VolumeMode:      Filesystem
          Capacity:        5Gi
          Node Affinity:   <none>
              Type:              CSI (a Container Storage Interface (CSI) volume source)
              Driver:            csi.vsphere.vmware.com
              VolumeHandle:      e4073a6d-642e-4dff-8f4a-b4e3a47c4bbd
              ReadOnly:          false
              VolumeAttributes:      storage.kubernetes.io/csiProvisionerIdentity=1586239648866-8081-csi.vsphere.vmware.com
                                     type=vSphere CNS Block Volume
          Events:                <none>
    If successfully created, PersistentVolume is available in the output, and VolumeHandle key is populated.

    The Status must display as Bound. You can also see that the Claim is set to the above PersistentVolumeClaim name example-vanilla-rwo-pvc.