Updated on 2024-11-11 GMT+08:00

PersistentVolumeClaims (PVCs)

A PVC describes a workload's request for storage resources. This request consumes existing PVs in the cluster. If there is no PV available, underlying storage and PVs are dynamically created. When creating a PVC, you need to describe the attributes of the requested persistent storage, such as the size of the volume and the read/write permissions.

Notes and Constraints

When a PVC is created, the system checks whether there is an available PV with the same configuration in the cluster. If yes, the PVC binds the available PV to the cluster. If no PV meets the matching conditions, the system dynamically creates a storage volume.

Description

PVC Field

PV Field

Matching Logic

region

pvc.metadata.labels (failure-domain.beta.kubernetes.io/region or topology.kubernetes.io/region)

pv.metadata.labels (failure-domain.beta.kubernetes.io/region or topology.kubernetes.io/region)

Defined or not defined at the same time. If defined, the settings must be consistent.

zone

pvc.metadata.labels (failure-domain.beta.kubernetes.io/zone or topology.kubernetes.io/zone)

pv.metadata.labels (failure-domain.beta.kubernetes.io/zone or topology.kubernetes.io/zone)

Defined or not defined at the same time. If defined, the settings must be consistent.

EVS disk type

pvc.metadata.annotations (everest.io/disk-volume-type)

pv.spec.csi.volumeAttributes (everest.io/disk-volume-type)

Defined or not defined at the same time. If defined, the settings must be consistent.

Enterprise project ID

pvc.metadata.annotations(everest.io/enterprise-project-id)

pv.spec.csi.volumeAttributes(everest.io/enterprise-project-id)

Defined or not defined at the same time. If defined, the settings must be consistent.

accessMode

accessMode

accessMode

The settings must be consistent.

Storage class

storageclass

storageclass

The settings must be consistent.

Volume Access Modes

PVs can be mounted to the host system only in the mode supported by underlying storage resources. For example, a file storage system can be read and written by multiple nodes, but an EVS disk can be read and written by only one node.

  • ReadWriteOnce: A volume can be mounted as read-write by a single node. This access mode is supported by EVS.
  • ReadWriteMany: A volume can be mounted as read-write by multiple nodes. This access mode is supported by SFS and OBS.
Table 1 Supported access modes

Storage Type

ReadWriteOnce

ReadWriteMany

EVS

×

SFS

×

OBS

×

Enterprise Project Support

To use this function, the everest add-on must be upgraded to 1.2.33 or later.

  • Using a Storage Class to Create a PVC:

    CCE allows you to specify an enterprise project when creating EVS disks and OBS PVCs. The created storage resources (EVS disks and OBS) belong to the specified enterprise project. The enterprise project can be the enterprise project to which the cluster belongs or the default enterprise project.

    If no enterprise project is specified, the enterprise project specified in StorageClass will be used by default for creating storage resources.
    • For a custom StorageClass, you can specify an enterprise project in StorageClass. For details, see Specifying an Enterprise Project for Storage Classes. If no enterprise project is specified in StorageClass, the default enterprise project is used.
    • For the csi-disk and csi-obs storage classes provided by CCE, the created storage resources belong to the default enterprise project.
  • Using a PV to Create a PVC:

    When you create a PVC using a PV, ensure that everest.io/enterprise-project-id specified in the PVC and PV are the same because an enterprise project has been specified during storage resource creation. Otherwise, the PVC and PV cannot be bound.

Using a Storage Class to Create a PVC

StorageClass describes the storage class used in the cluster. You need to specify StorageClass to dynamically create PVs and underlying storage resources when creating a PVC.

Using the CCE Console

  1. Log in to the CCE console.
  2. Go to the cluster details page, choose Storage from the navigation pane, and click the PersistentVolumeClaims (PVCs) tab.
  3. Click Create PVC in the upper right corner. In the dialog box displayed, set the PVC parameters.

    • Creation Method: Select Storage class.
    • PVC Name: Enter a PVC name.
    • Storage Class: Select the required storage class. The following storage resources can be dynamically provisioned:
      • csi-disk: EVS disk.
      • csi-obs: OBS bucket.
    • AZ (supported only by EVS): Select the AZ where the EVS disk is located.
    • Disk Type: Select an EVS disk type. EVS disk types vary in different regions.
      • High I/O
      • Ultra-high I/O
    • Access Mode: ReadWriteOnce and ReadWriteMany are supported. For details, see Volume Access Modes.
    • Capacity (GiB) (supported only by EVS and SFS): storage capacity. This parameter is not available for OBS.
    • Secret (supported only for OBS): Select an access key for OBS. For details, see Using a Custom AK/SK to Mount an OBS Volume.
    • Enterprise Project (supported only for EVS and OBS): Select an enterprise project to which the cluster belongs or use the default enterprise project.

  4. Click Create.

Using YAML

Example YAML for EVS

  • failure-domain.beta.kubernetes.io/region: region where the cluster is located.
  • failure-domain.beta.kubernetes.io/zone: AZ where the EVS volume is created. It must be the same as the AZ planned for the workload.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-evs-auto-example
  namespace: default
  annotations:
    everest.io/disk-volume-type: SSD    # EVS disk type.
    
    everest.io/enterprise-project-id: 86bfc701-9d9e-4871-a318-6385aa368183  # (Optional) Enterprise project ID. Only the enterprise project to which the cluster belongs and the default enterprise project are supported. The value 0 indicates the default enterprise project. Everest must be upgraded to 1.2.33 or later.
  labels:
    failure-domain.beta.kubernetes.io/region: eu-west-101
    failure-domain.beta.kubernetes.io/zone: eu-west-101a
spec:
  accessModes:
  - ReadWriteOnce               # The value must be ReadWriteOnce for EVS.
  resources:
    requests:
      storage: 10Gi             # EVS disk capacity, ranging from 1 to 32768.
  storageClassName: csi-disk    # The storage class type is EVS.

Example YAML for OBS:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: obs-warm-provision-pvc
  namespace: default
  annotations:
    everest.io/obs-volume-type: STANDARD      # OBS bucket type. Currently, standard (STANDARD) and infrequent access (WARM) are supported.
    csi.storage.k8s.io/fstype: obsfs          # File type. obsfs indicates to create a parallel file system (recommended), and s3fs indicates to create an OBS bucket.
    everest.io/enterprise-project-id: 86bfc701-9d9e-4871-a318-6385aa368183  # (Optional) Enterprise project ID. Only the enterprise project to which the cluster belongs and the default enterprise project are supported. The value 0 indicates the default enterprise project. Everest must be upgraded to 1.2.33 or later.
spec:
  accessModes:
  - ReadWriteMany             # The value must be ReadWriteMany for OBS.
  resources:
    requests:
      storage: 1Gi                 # This field is valid only for verification (fixed to 1, cannot be empty or 0). The value setting does not take effect for OBS buckets.
  storageClassName: csi-obs        # The storage class type is OBS.

Using a PV to Create a PVC

If a PV has been created, you can create a PVC to apply for PV resources.

Using the CCE Console

  1. Log in to the CCE console.
  2. Go to the cluster details page, choose Storage from the navigation pane, and click the PersistentVolumeClaims (PVCs) tab.
  3. Click Create PVC in the upper right corner. In the dialog box displayed, set the PVC parameters.

    • Creation Method: Select Existing volume.
    • PVC Name: Enter a PVC name.
    • Volume Type: Select your required volume type.
      • EVS
      • SFS
      • OBS
    • Associate Volume: Select the volume to be associated, that is, the PV.

  4. Click Create.

Using YAML

Example YAML for EVS

  • failure-domain.beta.kubernetes.io/region: region where the cluster is located.
  • failure-domain.beta.kubernetes.io/zone: AZ where the EVS volume is created. It must be the same as the AZ planned for the workload.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-test
  namespace: default
  annotations:
    everest.io/disk-volume-type: SAS                                # EVS disk type.
    
    volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner
    everest.io/enterprise-project-id: 86bfc701-9d9e-4871-a318-6385aa368183  # (Optional) If an enterprise project is specified, ensure that the value is the same as that of everest.io/enterprise-project-id specified in the PV. Otherwise, the PVC cannot be bound.
  labels:
    failure-domain.beta.kubernetes.io/region: eu-west-101
    failure-domain.beta.kubernetes.io/zone: eu-west-101a
spec:
  accessModes:
  - ReadWriteOnce               # The value must be ReadWriteOnce for EVS.
  resources:
    requests:
      storage: 10Gi              
  storageClassName: csi-disk     # Storage class name. The value is csi-disk for EVS.
  volumeName: cce-evs-test       # PV name.

Example YAML for SFS:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-sfs-test
  namespace: default
  annotations:
    volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner
spec:
  accessModes:
  - ReadWriteMany              # The value must be ReadWriteMany for SFS.
  resources:
    requests:
      storage: 100Gi           # Requested PVC capacity.
  storageClassName: csi-nas    # Storage class name. The value is csi-nas for SFS.
  volumeName: cce-sfs-test     # PV name.

Example YAML for OBS:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-obs-test
  namespace: default
  annotations:
    everest.io/obs-volume-type: STANDARD                         # OBS bucket type. Currently, standard (STANDARD) and infrequent access (WARM) are supported.
    csi.storage.k8s.io/fstype: s3fs                              # File type. obsfs indicates to create a parallel file system (recommended), and s3fs indicates to create an OBS bucket.
    csi.storage.k8s.io/node-publish-secret-name: test-user
    csi.storage.k8s.io/node-publish-secret-namespace: default
    volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner
    everest.io/enterprise-project-id: 86bfc701-9d9e-4871-a318-6385aa368183  # (Optional) If an enterprise project is specified, ensure that the value is the same as that of everest.io/enterprise-project-id specified in the PV. Otherwise, the PVC cannot be bound.
spec:
  accessModes:
  - ReadWriteMany             # The value must be ReadWriteMany for OBS.
  resources:
    requests:
      storage: 1Gi            # Requested PVC capacity. This field is valid only for verification (fixed to 1, cannot be empty or 0). The value setting does not take effect for OBS buckets.
  storageClassName: csi-obs   # Storage class name. The value is csi-obs for OBS.
  volumeName: cce-obs-test    # PV name.

Using a Snapshot to Creating a PVC

The disk type and disk mode of the created EVS PVC are consistent with those of the snapshot's source EVS disk.

Using the CCE Console

  1. Log in to the CCE console.
  2. Click the cluster name and go to the cluster console. Choose Storage from the navigation pane, and click the Snapshots and Backups tab.
  3. Locate the snapshot for which you want to create a PVC, click Create PVC, and specify the PVC name in the displayed dialog box.
  4. Click Create.

Creating from YAML

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-test
  namespace: default
  annotations:
    everest.io/disk-volume-type: SSD     # EVS disk type, which must be the same as that of the source EVS disk of the snapshot.
  labels:
    failure-domain.beta.kubernetes.io/region: eu-west-101
    failure-domain.beta.kubernetes.io/zone: 
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: '10'
  storageClassName: csi-disk
  dataSource:
    name: cce-disksnap-test             # Snapshot name
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io