(kubectl) Creating a PV from an Existing SFS File System
Scenario
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.
Prerequisites
You have created a CCE cluster and installed the CSI plug-in (everest) in the cluster.
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.
- Multiple PVs can use the same SFS file system with the following restrictions:
- An error may occur if multiple PVCs/PVs that use the same underlying SFS file system are mounted to the same pod.
- The persistentVolumeReclaimPolicy parameter in the PVs must be set to Retain. Otherwise, when a PV is deleted, the associated underlying SFS file system may be deleted. In this case, other PVs associated with the underlying SFS file system may be abnormal.
- When the underlying SFS file system is repeatedly used, it is recommended that ReadWriteMany be implemented at the application layer to prevent data overwriting and loss.
Procedure
- Log in to the SFS console, create a file system, and record the file system ID, shared path, and capacity.
- 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-sfs-example.yaml and pvc-sfs-example.yaml.
touch pv-sfs-example.yaml pvc-sfs-example.yaml
- vi pv-sfs-example.yaml
Example YAML file for the PV:
apiVersion: v1 kind: PersistentVolume metadata: name: pv-sfs-example annotations: pv.kubernetes.io/provisioned-by: everest-csi-provisioner spec: mountOptions: - hard - timeo=600 - nolock accessModes: - ReadWriteMany capacity: storage: 10Gi claimRef: apiVersion: v1 kind: PersistentVolumeClaim name: pvc-sfs-example namespace: default csi: driver: nas.csi.everest.io fsType: nfs volumeAttributes: everest.io/share-export-location: sfs-nas01.cn-north-4.myhuaweicloud.com:/share-436304e8 storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisioner volumeHandle: 682f00bb-ace0-41d8-9b3e-913c9aa6b695 persistentVolumeReclaimPolicy: Delete storageClassName: csi-nasTable 1 Key parameters Parameter
Description
driver
Storage driver used to mount the volume. Set the driver to nas.csi.everest.io for the file system.
everest.io/share-export-location
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, as shown in Figure 1.
volumeHandle
File system ID.
On the management console, choose Service List > Storage > Scalable File Service. In the SFS file system list, click the name of the target file system and copy the content following ID on the page displayed.
persistentVolumeReclaimPolicy
The Delete and Retain policies are supported.
Delete: When a PVC is deleted, both the PV and the file system 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
File system size.
storageClassName
Name of the Kubernetes storage class. Set this field to csi-nas.
spec.mountOptions
Mount options.
If not specified, the following configurations are used by default. For details, see SFS Volume Mount Options.
To configure mount options, the everest add-on version must be 1.2.8 or later.
mountOptions: - vers=3 - timeo=600 - nolock - hard
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-sfs-example.yaml
Example YAML file for the PVC:
apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: volume.beta.kubernetes.io/storage-provisioner: everest-csi-provisioner name: pvc-sfs-example namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi storageClassName: csi-nas volumeName: pv-sfs-exampleTable 2 Key parameters Parameter
Description
storageClassName
Set this field to csi-nas. The value must be the same as that of the existing PV.
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.
- vi pv-sfs-example.yaml
- Create a PV.
kubectl create -f pv-sfs-example.yaml
- Create a PVC.
kubectl create -f pvc-sfs-example.yaml
Last Article: (kubectl) Automatically Creating an SFS Volume
Next Article: (kubectl) Creating a Deployment Mounted with an SFS Volume

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.