This section describes how to automatically create an OBS bucket. It is applicable when no underlying storage volume is available.
Reserve 1 GiB of memory for each obsfs process. For example, for a node with 4 vCPUs and 8 GiB of memory, an obsfs parallel file system should be mounted to no more than eight pods.
Parameter |
Description |
---|---|
PVC Type |
In this example, select OBS. |
PVC Name |
Enter the PVC name, which must be unique in the same namespace. |
Creation Method |
In this example, select Dynamically provision. |
Storage Classes |
The storage class of OBS volumes is csi-obs. |
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. |
Access Key (AK/SK) |
Custom: Customize a secret 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. Only secrets with the secret.kubernetes.io/used-by = csi label can be selected. The secret type is cfe/secure-opaque. If no secret is available, click Create Secret to create one.
|
You can choose Storage in the navigation pane and view the created PVC and PV on the PVCs and PVs tab pages, respectively.
Parameter |
Description |
---|---|
PVC |
Select an existing object storage volume. |
Mount Path |
Enter a mount path, for example, /tmp. This parameter indicates the container path to which a data volume will be mounted. Do not mount the volume to a system directory such as / or /var/run. Otherwise, containers will be malfunctional. 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, causing container startup failures or workload creation failures.
NOTICE:
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 machine 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 is 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: v1 kind: PersistentVolumeClaim metadata: name: pvc-obs-auto namespace: default annotations: everest.io/obs-volume-type: STANDARD # Object storage type. csi.storage.k8s.io/fstype: obsfs # Instance type. csi.storage.k8s.io/node-publish-secret-name: <your_secret_name> # Custom secret name. csi.storage.k8s.io/node-publish-secret-namespace: <your_namespace> # Namespace of the custom secret. spec: accessModes: - ReadWriteMany # The value must be ReadWriteMany for object storage. resources: requests: storage: 1Gi # OBS volume capacity. storageClassName: csi-obs # The storage class type is OBS.
Parameter |
Mandatory |
Description |
---|---|---|
everest.io/obs-volume-type |
Yes |
OBS storage class.
|
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. |
storage |
Yes |
Requested capacity in the PVC, in Gi. For OBS, this field is used only for verification (cannot be empty or 0). Its value is fixed at 1, and any value you set does not take effect for OBS. |
storageClassName |
Yes |
Storage class name. The storage class name of OBS volumes is csi-obs. |
kubectl apply -f pvc-obs-auto.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: web-demo namespace: default spec: replicas: 2 selector: matchLabels: app: web-demo template: metadata: labels: app: web-demo spec: containers: - name: container-1 image: nginx:latest volumeMounts: - name: pvc-obs-volume #Volume name, which must be the same as the volume name in the volumes field. mountPath: /data # Location where the storage volume is mounted. imagePullSecrets: - name: default-secret volumes: - name: pvc-obs-volume # Volume name, which can be customized. persistentVolumeClaim: 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 | grep web-demo
web-demo-846b489584-mjhm9 1/1 Running 0 46s web-demo-846b489584-wvv5s 1/1 Running 0 46s
kubectl exec web-demo-846b489584-mjhm9 -- ls /data kubectl exec web-demo-846b489584-wvv5s -- ls /data
If no result is returned for both pods, no file exists in the /data path.
kubectl exec web-demo-846b489584-mjhm9 -- touch /data/static
kubectl exec web-demo-846b489584-mjhm9 -- ls /data
Expected output:
static
kubectl delete pod 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 | grep web-demo
web-demo-846b489584-d4d4j 1/1 Running 0 110s web-demo-846b489584-wvv5s 1/1 Running 0 7m50s
kubectl exec web-demo-846b489584-d4d4j -- ls /data
Expected output:
static
If the static file still exists, the data can be stored persistently.
kubectl get pod | grep web-demo
web-demo-846b489584-d4d4j 1/1 Running 0 7m web-demo-846b489584-wvv5s 1/1 Running 0 13m
kubectl exec web-demo-846b489584-d4d4j -- touch /data/share
kubectl exec web-demo-846b489584-d4d4j -- ls /data
Expected output:
share static
kubectl exec web-demo-846b489584-wvv5s -- ls /data
Expected output:
share static
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.
Operation |
Description |
Procedure |
---|---|---|
Updating an access key |
Update the access key of object storage on the CCE console. |
|
Viewing events |
You can 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 |
You can view, copy, and download the YAML files of a PVC or PV. |
|