To run stateful workloads on Tanzu Kubernetes 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 Supervisor Namespace.
Containers by default are ephemeral and stateless. For stateful workloads, a common approach is to create a persistent volume claim (PVC). You can use a PVC to mount the persistent volumes and access storage. 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.
- Review the documentation Storage in vSphere with Tanzu.
- Log in to the target Tanzu Kubernetes cluster. See Connect to a Tanzu Kubernetes Cluster as a vCenter Single Sign-On User.
- Switch to the namespace where the cluster is running.
kubectl config use-context NAMESPACE
- List the available storage classes.
kubectl get storageclasses
- Create a YAML file that contains the PVC configuration.
Use the following example. Replace the
storagevariable values with yours.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteOnce storageClassName: gold resources: requests: storage: 3Gi
- Apply the PVC to the cluster.
kubectl apply -f PVC-NAME.yaml
- Verify the status of the persistent volume claim.
kubectl get pvcThe PVC is listed and available for use. The PVC also appears in the Supervisor Namespace because the storage comes out of its quota.