You can statically create a block volume in a Tanzu Kubernetes cluster using an unused persistent volume claim (PVC) from the Supervisor Cluster.

The PVC must satisfy the following conditions:
  • The PVC is present in the same namespace where the Tanzu Kubernetes cluster resides.
  • The PVC is not attached to a vSphere Pod in the Supervisor Cluster or a pod in any Tanzu Kubernetes cluster.

Using static provisioning, you can also reuse in a new Tanzu Kubernetes cluster a PVC that is no longer needed by another Tanzu Kubernetes cluster. To do this, change the Reclaim policy of the persistent volume (PV) in the original Tanzu Kubernetes cluster to Retain, and then delete the corresponding PVC.

Follow these steps to statically create a PVC in a new Tanzu Kubernetes cluster using the information from the leftover underlying volume.

Procedure

  1. Note the name of the original PVC in the Supervisor Cluster.
    If you are reusing the PVC from an old Tanzu Kubernetes cluster, you can retrieve the PVC name from the volumeHandle of the old PV object in the Tanzu Kubernetes cluster.
  2. Create a PV.
    In the YAML file, specify the values of the following items:
    • For storageClassName, you can enter the storage class name that is used by your PVC in the Supervisor Cluster.
    • For volumeHandle, enter the PVC name that you obtained in Step 1.
    If you are reusing a volume from another Tanzu Kubernetes cluster, delete the PVC and PV objects from the old Tanzu Kubernetes cluster before creating a PV in the new Tanzu Kubernetes cluster.
    Use the following YAML manifest as an example.
       apiVersion: v1
       kind: PersistentVolume
       metadata:
         name: static-tkg-block-pv
         annotations:
           pv.kubernetes.io/provisioned-by: csi.vsphere.vmware.com
       spec:
         storageClassName: gc-storage-profile
         capacity:
           storage: 2Gi
         accessModes:
           - ReadWriteOnce
         persistentVolumeReclaimPolicy: Delete
         claimRef:
           namespace: default
           name: static-tkg-block-pvc
         csi:
           driver: "csi.vsphere.vmware.com"
           volumeAttributes:
             type: "vSphere CNS Block Volume"
           volumeHandle: "supervisor-block-pvc-name"  # Enter the PVC name from the Supervisor cluster.
  3. Create a PVC to match the PV object you created in Step 2.
    Set the storageClassName to the same value as in the PV.
       kind: PersistentVolumeClaim
       apiVersion: v1
       metadata:
         name: static-tkg-block-pvc
       spec:
         accessModes:
           - ReadWriteOnce
         resources:
           requests:
             storage: 2Gi
         storageClassName: gc-storage-profile
         volumeName: static-tkg-block-pv
  4. Verify that the PVC is bound to the PV that you created.
    $ kubectl get pv,pvc
     NAME                                    CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                          STORAGECLASS         REASON   AGE
     persistentvolume/static-tkg-block-pv    2Gi        RWO            Delete           Bound    default/static-tkg-block-pvc   gc-storage-profile            10s
    
     NAME                                         STATUS   VOLUME                CAPACITY   ACCESS MODES   STORAGECLASS         AGE
     persistentvolumeclaim/static-tkg-block-pvc   Bound    static-tkg-block-pv   2Gi        RWO            gc-storage-profile   10s