You can statically create a block volume in a TKG Service cluster using an unused persistent volume claim (PVC) from Supervisor.
The PVC must satisfy the following conditions:
- The PVC is present in the same namespace where the TKG cluster resides.
- The PVC is not already attached to a pod in any TKG cluster or to a vSphere Pod in Supervisor.
Using static provisioning, you can also reuse in a new TKG cluster a PVC that is no longer needed by another TKG cluster. To do this, change the Reclaim policy
of the persistent volume (PV) in the original TKG cluster to Retain
, and then delete the corresponding PVC.
Follow these steps to statically create a PVC in a new TKG cluster using the information from the leftover underlying volume.
Procedure
- Note the name of the original PVC in the Supervisor.
If you are reusing the PVC from an old TKG cluster, you can retrieve the PVC name from the
volumeHandle of the old PV object in the TKG cluster.
- 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.
- For volumeHandle, enter the PVC name that you obtained.
If you are reusing a volume from another TKG cluster, delete the PVC and PV objects from the old TKG cluster before creating a PV in the new TKG 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.
- Create a PVC to match the PV object you created.
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
- 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