When deploying applications in a CCE cluster, you typically need persistent object storage for service data. Without dynamic provisioning, you must manually create a bucket on the OBS console and define a PV and PVC in the cluster. This process is complex. To simplify this, you can use dynamic volume provisioning: declare a StorageClass in your PVC, and OBS buckets are automatically created with PVs generated and bound on demand. This enables pay-per-use, on-demand object storage. This section describes how to use object storage through dynamic PVs in CCE.
Dynamic OBS volume provisioning is an automated process managed by the Everest CSI driver, which handles bucket creation, PV generation, and binding. The core process is as follows.
Dynamic Provisioning for OBS Buckets | Description |
|---|---|
|
|
Parameter | Description |
|---|---|
PVC Type | In this example, select OBS. |
PVC Name | Enter the PVC name, which must be unique in a namespace. |
Creation Method |
In this example, select Dynamically provision. |
Storage Classes | The default StorageClass name of OBS volumes is csi-obs. You can customize a StorageClass and configure its reclaim policy and binding mode. For details, see Basic StorageClass Settings. |
(Optional) Storage Volume Name Prefix | Available only when the cluster version is v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later, and Everest v2.4.15 or later is installed in the cluster. This parameter specifies the name of the underlying storage that is automatically created. The actual underlying storage name is in the format of "Storage volume name prefix + PVC UID". If this parameter is left blank, the default prefix pvc will be used. For example, if the storage volume name prefix is set to test, the actual underlying storage name is test-{UID}. |
Instance Type |
|
OBS Class | You can select the following object bucket types: |
Access Mode | OBS volumes support only ReadWriteMany, indicating that a storage volume can be mounted to multiple nodes in read/write mode. For details, see Volume Access Modes. |
AK/SK |
CAUTION: If the AK/SK is deleted or disabled accidentally, the container cannot use the OBS volume. |
Enterprise Project | An enterprise project manages multiple resources by category. Resources and projects across cloud service regions can be grouped into a single enterprise project. For example, an enterprise can classify resources by department or project group, and place relevant resources in the same enterprise project for unified management. This parameter is available only for enterprise accounts with enterprise projects enabled. |
Resource Tag | You can add resource tags to classify resources. This is supported only when the Everest version in the cluster is 2.4.204 or later. NOTE: After a dynamic PV of the OBS type is created, the resource tags cannot be updated on the CCE console. To update OBS resource tags, go to the OBS console. |
You can choose Storage in the navigation pane and view the created PVC and PV on the PVCs and PVs tabs, respectively.
Mount and use storage volumes. For details about the parameters, see Table 1. For other parameters, see Workloads.
Parameter | Description |
|---|---|
PVC | Select an existing OBS volume. |
Mount Path | Enter a mount path, for example, /tmp. This parameter specifies a container path to which a data volume will be mounted. Do not mount the volume to a system directory such as / or /var/run. This may lead to container errors. Mount the volume to an empty directory. If the directory is not empty, ensure that there are no files that affect container startup. Otherwise, the files will be replaced, leading to container startup failures or workload creation failures. If a volume is mounted to a high-risk directory, use an account with minimum permissions to start the container. Otherwise, high-risk files on the host may be damaged. |
Subpath | Enter the subpath of the storage volume and mount a path in the storage volume to the container. In this way, different folders of the same storage volume can be used in a single pod. tmp, for example, indicates that data in the mount path of the container is stored in the tmp folder of the storage volume. If this parameter is left blank, the root path will be used by default. |
Permission |
|
In this example, the disk is mounted to the /data path of the container. The container data generated in this path is stored in the OBS volume.
After the workload is created, the data in the container mount directory will be persistently stored. Verify the storage by referring to Verifying Data Persistence and Sharing.
apiVersion: v1kind: PersistentVolumeClaimmetadata:name: pvc-obs-autonamespace: defaultannotations:everest.io/obs-volume-type: STANDARD # Object storage typecsi.storage.k8s.io/fstype: obsfs # Instance typecsi.storage.k8s.io/node-publish-secret-name: <your_secret_name> # Custom secret namecsi.storage.k8s.io/node-publish-secret-namespace: <your_namespace> # Namespace of the custom secreteverest.io/enterprise-project-id: <your_enterprise_project_id> # (Optional) Enterprise project ID of the new OBS volumeeverest.io/csi.volume-name-prefix: test # (Optional) Volume name prefix of the automatically-created underlying storagespec:accessModes:- ReadWriteMany # The value must be ReadWriteMany for OBS volumes.resources:requests:storage: 1Gi # OBS volume capacitystorageClassName: csi-obs # The StorageClass is OBS.
Parameter | Mandatory | Description |
|---|---|---|
everest.io/obs-volume-type | Yes | OBS StorageClass.
|
csi.storage.k8s.io/fstype | Yes | Instance type. The value can be obsfs or s3fs.
|
csi.storage.k8s.io/node-publish-secret-name | No | Custom secret name. (Recommended) Select this option if you want to assign different user permissions to different OBS storage devices. For details, see Using a Custom Access Key (AK/SK) to Mount an OBS Volume. |
csi.storage.k8s.io/node-publish-secret-namespace | No | Namespace of a custom secret. |
everest.io/enterprise-project-id | No | The ID of the enterprise project in which the OBS volume is created. It is applicable only to enterprise accounts with enterprise projects enabled. To obtain an enterprise project ID, log in to the EPS console, click the name of the target enterprise project, and copy the enterprise project ID. |
everest.io/csi.volume-name-prefix | No | (Optional) This parameter is available only when the cluster version is v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later, and Everest v2.4.15 or later is installed in the cluster. This parameter specifies the name of the underlying storage that is automatically created. The actual underlying storage name is in the format of "Storage volume name prefix + PVC UID". If this parameter is left blank, the default prefix pvc will be used. Enter 1 to 26 characters that cannot start or end with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. For example, if the storage volume name prefix is set to test, the actual underlying storage name is test-{UID}. |
storage | Yes | Requested capacity in the PVC, in Gi. For OBS, this parameter is only for verification. It must not be empty or 0, and its value is fixed at 1. Any value you set will not take effect. |
storageClassName | Yes | StorageClass name, which is csi-obs for an OBS volume. |
everest.io/obs-volume-tags | No | (Optional) This parameter is supported when the Everest version in the cluster is 2.4.204 or later. You can add resource tags to classify resources. You can create predefined tags on the TMS console. These tags are available to all resources that support tags. You can use these tags to improve the tag creation and resource migration efficiency. |
kubectl apply -f pvc-obs-auto.yaml
apiVersion: apps/v1kind: Deploymentmetadata:name: web-demonamespace: defaultspec:replicas: 2selector:matchLabels:app: web-demotemplate:metadata:labels:app: web-demospec:containers:- name: container-1image: nginx:latestvolumeMounts:- name: pvc-obs-volume # Volume name, which must be the same as the volume name in the volumes fieldmountPath: /data # Location where the storage volume is mountedimagePullSecrets:- name: default-secretvolumes:- name: pvc-obs-volume # Volume name, which is user-definedpersistentVolumeClaim:claimName: pvc-obs-auto # Name of the created PVC
kubectl apply -f web-demo.yaml
After the workload is created, you can try Verifying Data Persistence and Sharing.
kubectl get pod -n <namespace> | grep web-demo
Expected output:
kubectl exec -n <namespace> web-demo-846b489584-mjhm9 -- ls /datakubectl exec -n <namespace> web-demo-846b489584-wvv5s -- ls /data
If no result is returned for both pods, no file exists in the /data path.
kubectl exec -n <namespace> web-demo-846b489584-mjhm9 -- touch /data/static
kubectl exec -n <namespace> web-demo-846b489584-mjhm9 -- ls /data
Expected output:
static
kubectl delete pod -n <namespace> web-demo-846b489584-mjhm9
Expected output:
pod "web-demo-846b489584-mjhm9" deleted
After the deletion, the Deployment controller automatically creates a replica.
kubectl get pod -n <namespace> | grep web-demo
The expected output is as follows, in which web-demo-846b489584-d4d4j is the newly created pod:
kubectl exec -n <namespace> web-demo-846b489584-d4d4j -- ls /data
Expected output:
static
The static file is retained, indicating that the data can be stored persistently.
kubectl get pod -n <namespace> | grep web-demo
Expected output:
kubectl exec -n <namespace> web-demo-846b489584-d4d4j -- touch /data/share
Check the files in the /data path of the pod.
Expected output:
sharestatic
kubectl exec -n <namespace> web-demo-846b489584-wvv5s -- ls /data
Expected output:
sharestatic
After you create a file in the /data path of a pod, if the file is also created in the /data path of the other pod, the two pods share the same volume.
You can also perform the operations listed in Table 3.
Operation | Description | Procedure |
|---|---|---|
Updating an access key | Update the access key of object storage on the CCE console. |
|
Viewing events | View event names, event types, number of occurrences, Kubernetes events, first occurrence time, and last occurrence time of the PVC or PV. |
|
Viewing a YAML file | View, copy, or download the YAML file of a PVC or PV. |
|
Editing Reclaim Policy | Modify the reclaim policy of a PV. |
|