Skip to main content

What are PV and PVC?

A PV (PersistentVolume) in Managed Kubernetes is a resource used to store data. It is attached to pods but has a separate lifecycle, specified by its reclaim policy. This policy determines if a PV will continue to exist or will be deleted when a pod attached to it gets destroyed. A PV represents a piece of available storage. To use a PV, a user needs to create a PersistentVolumeClaim (PVC,) which is a request for storage. Kubernetes passes this request to a storage class, which creates PVs automatically in response to the PVC.

Create a PVC

Before you create a PVC, you need to create a storage class with the required disk type. Gcore provides the following disk types: To proceed with a PVC, follow the steps:
  1. Make sure the required disk type is available in your region. To do so, go to the Kubernetes tab, select the required region and click Create new cluster. Click the Volume type field and check which options are available on the drop-down list.
Create new cluster
If you create a storage class with a volume type that is not available in your region, the PV won’t work.
  1. Create a YAML file to create a storage class with the required disk type:
Enter your custom values instead:
  • csi-sc-cinderplugin-hiiops: Storage class name
  • ssd_hiiops: Disk type (standard, ssd_hiiops, or ssd_lowlatency)
  1. Run the kubectl command from the file directory:
You will get this output:
  1. Create a YAML file to configure a PVC:
Enter your custom values instead:
  • block-pvc: PVC name
  • csi-sc-cinderplugin-hiiops: Name of the created storage class
  • 1Gi: Storage size
  1. Run the kubectl command from the file directory:
You will get this output:
This means you have successfully created a PVC with a storage class of the required disk type. To connect the PVC to your pods, refer to the section below.

Bind your PVC to a pod

  1. Create a YAML file to bind the created storage class to your pod.
Enter your custom values instead:
  • mypod: Pod name
  • myfrontend: Container name
  • "/var/www/html": Destination inside the pod where to mount the storage class
  • mypd: Storage class name
  • block-pvc: Created PVC name
  1. Run the kubectl command from the file directory:
  1. You will get this output:
This means you have successfully connected the PVC to your pod, and its containers can now access the storage.

Resize a PVC

Gcore Managed Kubernetes offers you predefined storage classes for PVs. If you issue a PVC, Managed Kubernetes will provision a dynamic PV that matches the PVC’s specs. This means that to increase the size of a PV, you have to update the PVC that was used to create it.
Reducing the size of a PV is not supported
1. Find the PVC by querying all PVCs with this command:
2. Locate the storage field in your PVC spec and replace it with your desired size (e.g., 1 Ti, 250 Gi, etc.). An example PVC spec for 250 GB and the standard storage class could look like this:
3. Send it to your cluster with this command:
The update may take a few minutes to complete. 4. Check if the resize worked.