(kubectl) Creating a PV from an Existing OBS Bucket
Scenario
CCE allows you to use an existing OBS bucket to create a PersistentVolume (PV). You can create a PersistentVolumeClaim (PVC) and bind it to the PV.
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.
- To configure mount options, the everest add-on version must be 1.2.8 or later.
Procedure
- Log in to the OBS console, create an OBS bucket, and record the bucket name and storage class.
- Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
- Create two YAML files for creating the PV and PVC. Assume that the file names are pv-obs-example.yaml and pvc-obs-example.yaml.
touch pv-obs-example.yaml pvc-obs-example.yaml
- vi pv-obs-example.yaml Example YAML file for the PV:
apiVersion: v1 kind: PersistentVolume metadata: name: pv-obs-example annotations: pv.kubernetes.io/provisioned-by: everest-csi-provisioner spec: mountOptions: - umask=0027 - uid=10000 - gid=10000 accessModes: - ReadWriteMany capacity: storage: 1Gi claimRef: apiVersion: v1 kind: PersistentVolumeClaim name: pvc-obs-example namespace: default csi: driver: obs.csi.everest.io fsType: obsfs volumeAttributes: everest.io/obs-volume-type: STANDARD everest.io/region: cn-north-4 storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisioner volumeHandle: obs-normal-static-pv persistentVolumeReclaimPolicy: Retain storageClassName: csi-obsTable 1 Key parameters Parameter
Description
driver
Storage driver used to mount the volume. Set the driver to obs.csi.everest.io for the OBS volume.
everest.io/obs-volume-type
Storage class, including STANDARD (standard bucket) and WARM (infrequent access bucket).
everest.io/region
Region where the OBS bucket is deployed.
For details about the value of region, see Regions and Endpoints.
volumeHandle
OBS bucket name.
persistentVolumeReclaimPolicy
The Delete and Retain policies are supported.
Delete: When a PVC is deleted, both the PV and the object storage are deleted.
Retain: When a PVC is deleted, the PV and underlying storage resources are not deleted. Instead, you must manually delete these resources. After that, the PV is in the Released state and cannot be bound to the PVC again.
If high data security is required, you are advised to select Retain to prevent data from being deleted by mistake.
storage
Storage capacity in the unit of Gi. This parameter is set only to meet the PV format requirements. It can be set to any value. The actual OBS space size is not limited by this value.
storageClassName
Name of the Kubernetes storage class. Set this field to csi-obs.
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.
spec.mountOptions
Mount options. For details, see OBS Volume Mount Options.
To configure mount options, the everest add-on version must be 1.2.8 or later.
spec.claimRef.apiVersion
The value is fixed at v1.
spec.claimRef.kind
The value is fixed at PersistentVolumeClaim.
spec.claimRef.name
PVC name. The value is the same as the name of the PVC created in the next step.
spec.claimRef.namespace
Namespace of the PVC. The value is the same as the namespace of the PVC created in the next step.
- vi pvc-obs-example.yaml
Example YAML file for the PVC:
apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner everest.io/obs-volume-type: STANDARD csi.storage.k8s.io/fstype: obsfs name: pvc-obs-example namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi storageClassName: csi-obs volumeName: pv-obs-exampleTable 2 Key parameters Parameter
Description
volumeName
Name of the PV.
storage
Storage capacity in the unit of Gi. The value must be the same as the storage size of the existing PV.
storageClassName
Name of the Kubernetes storage class. Set this field to csi-obs.
everest.io/obs-volume-type
OBS volume type, which can be STANDARD (standard bucket) and WARM (infrequent access bucket).
csi.storage.k8s.io/fstype
File type, which 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.
- vi pv-obs-example.yaml
- Create the PV.
kubectl create -f pv-obs-example.yaml
- Create the PVC.
kubectl create -f pvc-obs-example.yaml
Last Article: (kubectl) Automatically Creating an OBS Volume
Next Article: (kubectl) Creating a Deployment Mounted with an OBS Volume
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.