You can dynamically create a persistent storage volume using an existing storage class and a persistent volume claim (PVC).
Dynamic PVC for TKG Clusters
To run stateful workloads on TKG clusters, you can create a persistent volume claim (PVC) to request persistent storage resources without knowing the details of the underlying storage infrastructure. The storage used for the PVC is allocated out of the storage quota for the vSphere Namespace.
The request dynamically provisions a persistent volume object and a matching virtual disk. The claim is bound to the persistent volume. When you delete the claim, the corresponding persistent volume object and the provisioned virtual disk are also deleted.
Creating the PVC, dynamically creates the backing persistent volume. The PVC references the
tkg-store storage class. The storage class is associated with the
vSphere Namespace where the target TKG cluster is provisioned. See
Using Storage Classes for Persistent Volumes for more information.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: tkg-cluster-pvc spec: accessModes: - ReadWriteMany storageClassName: tkg-store resources: requests: storage: 3Gi
Crete the PVC.
kubectl apply -f pvc_name.yaml
Check the PVC.
kubectl get pvc my-pvc
Specify the PVC in the pod or deployment spec. For example:
... volumes: - name: my-pvc persistentVolumeClaim: claimName: my-pvc