(kubectl) Automatically Creating an OBS Volume
Scenario
During the use of OBS, expected OBS buckets can be automatically created and mounted as volumes. Currently, standard and infrequent access OBS buckets are supported, which correspond to obs-standard and obs-standard-ia, respectively.
Prerequisites
- You have created a CCE cluster and installed the CSI plug-in (everest) in the cluster.
- The AK/SK has been uploaded. For details, see Preparations.
Notes and Constraints
The following configuration example applies to clusters of Kubernetes 1.15 or later.
Procedure
- Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
- Run the following commands to configure the pvc-obs-auto-example.yaml file, which is used to create a PVC.
touch pvc-obs-auto-example.yaml
vi pvc-obs-auto-example.yaml
Example YAML file:
apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: everest.io/obs-volume-type: STANDARD csi.storage.k8s.io/fstype: obsfs name: obs-warm-provision-pvc namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi storageClassName: csi-obsTable 1 Key parameters Parameter
Description
everest.io/obs-volume-type
OBS bucket type. Currently, standard (STANDARD) and infrequent access (WARM) buckets are supported.
name
Name of the PVC to be created.
accessModes
Only ReadWriteMany is supported. ReadWriteOnly is not supported.
storage
Storage capacity in the unit of Gi. For OBS buckets, 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 buckets.
csi.storage.k8s.io/fstype
File type. The value can be obsfs or s3fs. If the value is s3fs, an OBS bucket is created and mounted using s3fs. If the value is obsfs, an OBS parallel file system is created and mounted using obsfs. You are advised to set this field to obsfs.
- Run the following command to create the PVC.
kubectl create -f pvc-obs-auto-example.yaml
After the command is executed, an OBS bucket is created in the VPC to which the cluster belongs. You can click the bucket name in Storage > OBS to view the bucket or view it on the OBS console.
Last Article: Using OBS Volumes
Next Article: (kubectl) Creating a PV from an Existing OBS Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.