Creating PVCs

Create a PersistentVolumeClaim (PVC) and set the parameters for the requested PersistentVolume (PV) as needed.

You can create a PersistentVolumeClaim either through a visual UI form or by using a custom YAML orchestration file.

Prerequisites

Ensure that there is enough remaining storage quota in the namespace to satisfy the required storage size for this creation operation.

Example PersistentVolumeClaim:

# example-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: example-pvc
  namespace: k-1
  annotations: {}
  labels: {}
spec:
  storageClassName: cephfs
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 4Gi

Creating a Persistent Volume Claim by using the web console

  1. Go to Container Platform.

  2. Click on Storage > PersistentVolumeClaims (PVC) in the left sidebar.

  3. Click on Create PVC.

  4. Configure the parameters as required.

    Note: The following content is provided as an example using the form method; you can also switch to YAML mode to complete the operation.

    ParameterDescription
    NameThe name of the PersistentVolumeClaim, which must be unique within the current namespace.
    Creation Method- Dynamic Creation: Dynamically generates a PersistentVolume based on the storage class and binds it.
    - Static Binding: Matches and binds based on configured parameters and existing PersistentVolumes.
    Storage ClassAfter selecting the dynamic creation method, the platform will dynamically create the PersistentVolume as per the description in the specified storage class.
    Access Mode- ReadWriteOnce (RWO): Can be mounted by a single node in read-write mode.
    - ReadWriteMany (RWX): Can be mounted by multiple nodes in read-write mode.
    - ReadOnlyMany (ROX): Can be mounted by multiple nodes in read-only mode.

    Tip: It's recommended to consider the number of workload instances that are planned to bind to the current PersistentVolumeClaim and the type of deployment controller. For example, when creating a multi-instance deployment (Deployment), since all instances use the same PersistentVolumeClaim, it is not advisable to choose the RWO access mode, which can only attach to a single node.
    CapacityThe size of the requested PersistentVolume.
    Volume Mode- Filesystem: Binds the PersistentVolume as a file directory mounted into the Pod. This mode is available for any type of workload.
    - Block Device: Binds the PersistentVolume as a raw block device mounted into the Pod. This mode is available only for virtual machines.
    More- Labels
    - Annotations
    - Selector: After selecting the static binding method, you can use a selector to target PersistentVolumes that are labeled with specific tags. PersistentVolume labels can be used to denote special attributes of the storage, such as disk type or geographic location.
  5. Click on Create. Wait for the PersistentVolumeClaim to change to Bound status, indicating that the PersistentVolume has been successfully matched.

Creating a Persistent Volume Claim by using the CLI

kubectl apply -f example-pvc.yaml

Operations

  • Bind PersistentVolumeClaim: When creating applications or workloads that require persistent data storage, bind the PersistentVolumeClaim to request a compliant PersistentVolume.

  • Create a PersistentVolumeClaim using Volume Snapshots: This helps to back up application data and restore it as needed, ensuring the reliability of business application data. Please refer to Using Volume Snapshots.

  • Delete PersistentVolumeClaim: You can click the Actions button in the top right corner of the details page to delete the PersistentVolumeClaim as needed. Before deleting, please ensure that the PersistentVolumeClaim is not bound to any applications or workloads and that it does not contain any volume snapshots. After deleting the PersistentVolumeClaim, the platform will process the PersistentVolume according to the reclamation policy, which may clear data in the PersistentVolume and free storage resources. Please proceed with caution based on data security considerations.

Expanding PersistentVolumeClaim Storage Capacity by using the web console

  1. In the left navigation bar, click Storage > Persistent Volume Claims (PVC).

  2. Find the persistent volume claim and click ⋮ > Expand.

  3. Fill in the new capacity.

  4. Click Expand. The expansion process may take some time, please be patient.

Expanding Persistent Volume Claim Storage Capacity by using the CLI

kubectl patch pvc example-pvc -n k-1 --type='merge' -p '{
  "spec": {
    "resources": {
      "requests": {
        "storage": "6Gi"
      }
    }
  }
}'
INFO

When PVC expansion fails in Kubernetes, administrators can manually recover the Persistent Volume Claim (PVC) state and cancel the expansion request. See Recover From PVC Expansion Failure

Additional resources