Help Center> Cloud Container Engine> User Guide> Old Console> Storage (CSI)> OBS Volumes> (kubectl) Automatically Creating an OBS Volume

(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

  1. Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
  2. 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-obs
    Table 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.

  3. 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.