CCE allows you to use an existing file system to create a PersistentVolume (PV). After the creation is successful, create the corresponding PersistentVolumeClaim (PVC) and bind it to the PV.
You have created a CCE cluster and installed the FlexVolume plug-in (storage-driver) in the cluster.
The following configuration example applies to clusters of Kubernetes 1.13 or earlier.
touch pv-sfs-example.yaml pvc-sfs-example.yaml
Kubernetes Version |
Description |
YAML Example |
---|---|---|
1.11 ≤ K8s version ≤ 1.13 |
Clusters from v1.11 to v1.13 |
|
K8s version = 1.9 |
Clusters of v1.9 |
Clusters from v1.11 to v1.13
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-sfs-example
annotations:
pv.kubernetes.io/provisioned-by: flexvolume-huawei.com/fuxinfs
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 10Gi
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: pvc-sfs-example
namespace: default
flexVolume:
driver: huawei.com/fuxinfs
fsType: nfs
options:
deviceMountPath: <your_deviceMountPath> # Shared storage path of your file.
fsType: nfs
volumeID: f6976f9e-2493-419b-97ca-d7816008d91c
persistentVolumeReclaimPolicy: Delete
storageClassName: nfs-rw
Parameter |
Description |
---|---|
driver |
Storage driver used to mount the volume. Set the driver to huawei.com/fuxinfs for the file system. |
deviceMountPath |
Shared path of the file system. On the management console, choose Service List > Storage > Scalable File Service. You can obtain the shared path of the file system from the Mount Address column. |
volumeID |
File system ID. To obtain the ID, log in to the CCE console, choose Resource Management > Storage, click the PVC name in the SFS tab page, and copy the PVC ID on the PVC details page. |
storage |
File system size. |
storageClassName |
Read/write mode supported by the file system. Currently, nfs-rw and nfs-ro are supported. |
spec.claimRef.apiVersion |
The value is fixed at v1. |
spec.claimRef.kind |
The value is fixed at PersistentVolumeClaim. |
spec.claimRef.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. |
apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: volume.beta.kubernetes.io/storage-class: nfs-rw volume.beta.kubernetes.io/storage-provisioner: flexvolume-huawei.com/fuxinfs name: pvc-sfs-example namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi volumeName: pv-sfs-example
Parameter |
Description |
---|---|
volume.beta.kubernetes.io/storage-class |
Read/write mode supported by the file system. nfs-rw and nfs-ro are supported. The value must be the same as that of the existing PV. |
volume.beta.kubernetes.io/storage-provisioner |
Must be set to flexvolume-huawei.com/fuxinfs. |
storage |
Storage capacity, in the unit of Gi. The value must be the same as the storage size of the existing PV. |
volumeName |
Name of the PV. |
Clusters of v1.9
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-sfs-example
namespace: default
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 10Gi
flexVolume:
driver: huawei.com/fuxinfs
fsType: nfs
options:
deviceMountPath: <your_deviceMountPath> # Shared storage path of your file.
fsType: nfs
kubernetes.io/namespace: default
volumeID: f6976f9e-2493-419b-97ca-d7816008d91c
persistentVolumeReclaimPolicy: Delete
storageClassName: nfs-rw
Parameter |
Description |
---|---|
driver |
Storage driver used to mount the volume. Set the driver to huawei.com/fuxinfs for the file system. |
deviceMountPath |
Shared path of the file system. On the management console, choose Service List > Storage > Scalable File Service. You can obtain the shared path of the file system from the Mount Address column. |
volumeID |
File system ID. To obtain the ID, log in to the CCE console, choose Resource Management > Storage, click the PVC name in the SFS tab page, and copy the PVC ID on the PVC details page. |
storage |
File system size. |
storageClassName |
Read/write mode supported by the file system. Currently, nfs-rw and nfs-ro are supported. |
apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: volume.beta.kubernetes.io/storage-class: nfs-rw volume.beta.kubernetes.io/storage-provisioner: flexvolume-huawei.com/fuxinfs name: pvc-sfs-example namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi volumeName: pv-sfs-example volumeNamespace: default
Parameter |
Description |
---|---|
volume.beta.kubernetes.io/storage-class |
Read/write mode supported by the file system. nfs-rw and nfs-ro are supported. The value must be the same as that of the existing PV. |
volume.beta.kubernetes.io/storage-provisioner |
The field must be set to flexvolume-huawei.com/fuxinfs. |
storage |
Storage capacity, in the unit of Gi. The value must be the same as the storage size of the existing PV. |
volumeName |
Name of the PV. |
The VPC to which the file system belongs must be the same as the VPC of the ECS VM to which the workload is planned.
kubectl create -f pv-sfs-example.yaml
kubectl create -f pvc-sfs-example.yaml