Using OBS Buckets Across Regions

By default, a pod can use OBS buckets only in the same region. CCE allows a workload to use OBS buckets across regions, which can improve resource utilization in some scenarios, but may also result in a higher latency.

Notes and Constraints

  • OBS can be used across regions only in CCE clusters of v1.15 and v1.19.
  • The everest add-on version must be 1.2.32 or later.
  • The node to which the storage is mounted must be able to access OBS buckets. Generally, the Internet or Direct Connect is used to access OBS buckets across regions. You can ping the endpoint of OBS on the node where OBS is located to check whether OBS is accessible.
  • Only PVs can use OBS buckets across regions, and then are bound to PVCs. The PV reclaim policy must be Retain. Storage classes cannot be used to dynamically create PVCs for using OBS buckets across regions.

Procedure

  1. Create the paas-obs-endpoint ConfigMap and configure the region and endpoint of OBS.

    The ConfigMap name is fixed to paas-obs-endpoint, and the namespace is fixed to kube-system.

    The region and endpoint are set in the format of key-value pairs. Replace <region_name> and <endpoint_address> with specific values. For details, see Regions and Endpoints. Use commas (,) to separate multiple values.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: paas-obs-endpoint   # The value must be paas-obs-endpoint.
      namespace: kube-system    # The value must be kube-system.
    data:
      obs-endpoint: |
        {"<region_name>": "<endpoint_address>"}

  2. Create the PV.

    Set everest.io/region to the region where OBS is located.
    kind: PersistentVolume
    apiVersion: v1
    metadata:
      name: testing-abc
      annotations:
        pv.kubernetes.io/bound-by-controller: 'yes'
        pv.kubernetes.io/provisioned-by: everest-csi-provisioner
    spec:
      capacity:
        storage: 1Gi
      csi:
        driver: obs.csi.everest.io
        volumeHandle: testing-abc             # OBS bucket name
        fsType: s3fs                          # obsfs indicates to create a parallel file system (recommended), and s3fs indicates to create an object bucket.
        volumeAttributes:
          everest.io/obs-volume-type: STANDARD
          everest.io/region: <region_name>       # Region where the OBS bucket resides. Replace it with a specific value.
          storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisioner
        nodePublishSecretRef:                 # AK/SK used for mounting an OBS bucket
          name: test-user
          namespace: default
      accessModes:
        - ReadWriteMany
      persistentVolumeReclaimPolicy: Retain   # The value must be Retain.
      storageClassName: csi-obs
      volumeMode: Filesystem

    nodePublishSecretRef is the access key (AK/SK) used for mounting the object storage volume. You need to use the AK/SK to create a secret, which will be used when creating a PV. For details, see Using a Custom AK/SK to Mount an OBS Volume.

  3. Create the PVC.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-test-abc
      namespace: default
      annotations:
        everest.io/obs-volume-type: STANDARD                         # OBS bucket type. Currently, standard (STANDARD) and infrequent access (WARM) are supported.
        csi.storage.k8s.io/fstype: s3fs                              # File type. obsfs indicates to create a parallel file system (recommended), and s3fs indicates to create an OBS bucket.
        volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner
    spec:
      accessModes:
      - ReadWriteMany             # For object storage, the value must be ReadWriteMany.
      resources:
        requests:
          storage: 1Gi            # Storage capacity of a PVC. This field is valid only for verification (fixed to 1, cannot be empty or 0). The value setting does not take effect for OBS buckets.
      storageClassName: csi-obs   # Storage class name. For object storage, the value is fixed to csi-obs.
      volumeName: testing-abc     # PV name

  4. Create a workload, select the PVC in the data storage option of the container settings, and add the created PVC. If the workload is successfully created, the OBS bucket can be used across regions.

    apiVersion: apps/v1 
    kind: Deployment 
    metadata: 
       name: obs-deployment-example                       # Workload name
      namespace: default 
    spec: 
      replicas: 1 
      selector: 
        matchLabels: 
          app: obs-deployment-example 
      template: 
        metadata: 
          labels: 
            app: obs-deployment-example 
        spec: 
          containers: 
          - image: nginx
            name: container-0 
            volumeMounts: 
            - mountPath: /tmp                       # Mount path
              name: pvc-obs-example 
          restartPolicy: Always
          imagePullSecrets:
            - name: default-secret
          volumes: 
          - name: pvc-obs-example  
            persistentVolumeClaim: 
              claimName: pvc-test-abc               # PVC name