This section describes how to use an existing Object Storage Service (OBS) bucket to statically create PVs and PVCs for data persistence and sharing in workloads.
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 Create new to create both a PV and PVC on the console. |
PVa | Select an existing PV in the cluster. For details about how to create a PV, see "Creating a storage volume" in Related Operations. You do not need to specify this parameter in this example. |
OBSb | Click Select OBS. On the displayed page, select the OBS volume that meets your requirements and click OK. |
PV Nameb | Enter the PV name, which must be unique in the same cluster. |
Access Modeb | 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. |
Reclaim Policyb | You can select Delete or Retain to specify the reclaim policy of the underlying storage when the PVC is deleted. For details, see PV Reclaim Policy. NOTE: If multiple PVs use the same OBS volume, use Retain to prevent the underlying volume from being deleted with a PV. |
Access Key (AK/SK)b |
CAUTION: If the AK/SK is deleted or disabled accidentally, the container cannot use the OBS volume. |
Mount Optionsb | Enter the mounting parameter key-value pairs. For details, see Configuring OBS Mount Options. |
a: The parameter is available when Creation Method is set to Use existing.
b: The parameter is available when Creation Method is set to Create new.
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: PersistentVolumemetadata:annotations:pv.kubernetes.io/provisioned-by: everest-csi-provisionereverest.io/reclaim-policy: retain-volume-only # (Optional) The underlying volume is retained when the PV is deleted.name: pv-obs # PV namespec:accessModes:- ReadWriteMany # Access mode. The value must be ReadWriteMany for OBS.capacity:storage: 1Gi # Storage capacity. This parameter is only for verification. It must not be empty or 0, but the specified size will not take effect.csi:driver: obs.csi.everest.io # Dependent storage driver for the mountingfsType: obsfs # Instance typevolumeHandle: <your_volume_id> # Name of the OBS volumevolumeAttributes:storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisionereverest.io/obs-volume-type: STANDARDeverest.io/region: <your_region> # Region where the OBS volume iseverest.io/enterprise-project-id: <your_enterprise_project_id> # (Optional) Enterprise project ID. If an enterprise project is specified, you must specify the same enterprise project when creating a PVC. Otherwise, the PVC cannot bind to a PV.nodePublishSecretRef: # Custom secret of the OBS volumename: <your_secret_name> # Custom secret namenamespace: <your_namespace> # Namespace of the custom secretpersistentVolumeReclaimPolicy: Retain # Reclaim policystorageClassName: csi-obs # StorageClass namemountOptions: [] # Mount options
Parameter | Mandatory | Description |
|---|---|---|
everest.io/reclaim-policy: retain-volume-only | No | Optional. Only retain-volume-only is supported. This parameter is valid only when the Everest version is 1.2.9 or later and the reclaim policy is Delete. If the reclaim policy is Delete and the current value is retain-volume-only, the associated PV is deleted while the underlying storage volume is retained, when a PVC is deleted. |
fsType | Yes | Instance type. The value can be obsfs or s3fs.
|
volumeHandle | Yes | OBS volume name. |
everest.io/obs-volume-type | Yes | OBS StorageClass.
|
everest.io/region | Yes | Region where the OBS bucket is deployed. For details about its value, see Regions and Endpoints. |
everest.io/enterprise-project-id | No | This parameter specifies the ID of the enterprise project where an OBS volume is created. It is applicable only to enterprise accounts with enterprise projects enabled. If an enterprise project is specified, you must specify the same enterprise project when creating a PVC. Otherwise, the PVC cannot bind to a PV. How to obtain: On the OBS console, choose Buckets or Parallel File Systems in the navigation pane. Click the name of the OBS bucket to access its details page. In the Basic Information area, locate the enterprise project and click it to access the enterprise project console. Copy the corresponding ID to obtain the ID of the enterprise project to which the object storage belongs. |
nodePublishSecretRef | No | Access key (AK/SK) used for mounting the object storage volume. You can use the AK/SK to create a secret and mount it to the PV. For details, see Using a Custom Access Key (AK/SK) to Mount an OBS Volume. Example: |
mountOptions | No | Mount options. For details, see Configuring OBS Mount Options. |
persistentVolumeReclaimPolicy | Yes | A reclaim policy is supported when the cluster version is or later than 1.19.10 and the Everest version is or later than 1.2.9. The Delete and Retain reclaim policies are supported. For details, see PV Reclaim Policy. If multiple PVs use the same OBS volume, use Retain to prevent the underlying volume from being deleted with a PV. Delete:
Retain: When a PVC is deleted, both the PV and underlying storage resources will be retained. You need to manually delete these resources. After the PVC is deleted, the PV is in the Released state and cannot be bound to a PVC again. If you want to continue using the underlying storage resources, delete the PV first. Then, create a new PV and PVC and associate them with the underlying storage resources. |
storage | Yes | Storage capacity, 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. |
kubectl apply -f pv-obs.yaml
apiVersion: v1kind: PersistentVolumeClaimmetadata:name: pvc-obsnamespace: defaultannotations:volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisionereverest.io/obs-volume-type: STANDARDcsi.storage.k8s.io/fstype: obsfscsi.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. If an enterprise project is specified during PV creation, you must specify the same enterprise project when creating a PVC. Otherwise, the PVC cannot be bound to the PV.spec:accessModes:- ReadWriteMany # The value must be ReadWriteMany for OBS.resources:requests:storage: 1GistorageClassName: csi-obs # StorageClass name, which must be the same as that of the PVvolumeName: pv-obs # PV name
Parameter | Mandatory | Description |
|---|---|---|
csi.storage.k8s.io/node-publish-secret-name | No | Name of the custom secret specified in the PV. |
csi.storage.k8s.io/node-publish-secret-namespace | No | Namespace of the custom secret specified in the PV. |
everest.io/enterprise-project-id | No | This parameter specifies the ID of the enterprise project where an OBS volume is created. It is applicable only to enterprise accounts with enterprise projects enabled. How to obtain: On the OBS console, choose Buckets or Parallel File Systems in the navigation pane. Click the name of the OBS bucket to access its details page. In the Basic Information area, locate the enterprise project and click it to access the enterprise project console. Copy the corresponding ID to obtain the ID of the enterprise project to which the object storage belongs. |
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 must be the same as the StorageClass of the PV in 1. StorageClass name, which is csi-obs for an OBS volume. |
volumeName | Yes | PV name, which must be the same as the PV name in 1. |
kubectl apply -f pvc-obs.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 # 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 4.
Operation | Description | Procedure |
|---|---|---|
Creating a storage volume (PV) | Create a PV on the CCE console. |
|
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. |
|