(kubectl) Creating a PV from an Existing SFS Turbo File System
Scenario
CCE allows you to use an existing SFS Turbo file system to create a PersistentVolume (PV). After the creation is successful, 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.
Notes and Constraints
- The configuration example in this section 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.
- Only an SFS Turbo file system in the same VPC as the cluster and in the same subnet as the node is supported.
- Inbound ports (111, 445, 2049, 2051, and 20048) must be enabled for the security group to which the SFS Turbo file system belongs.
- Multiple PVs can use the same SFS Turbo file system with the following restrictions:
- An error may occur if multiple PVCs/PVs that use the same underlying SFS Turbo 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 Turbo file system may be deleted. In this case, other PVs associated with the underlying SFS Turbo file system may be abnormal.
- When the underlying SFS Turbo 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-sfsturbo-example.yaml and pvc-sfsturbo-example.yaml.
touch pv-sfsturbo-example.yaml pvc-sfsturbo-example.yaml
- vi pv-sfsturbo-example.yaml Example YAML file for the PV:
apiVersion: v1 kind: PersistentVolume metadata: name: pv-sfsturbo-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-sfsturbo-example namespace: default csi: driver: sfsturbo.csi.everest.io fsType: nfs volumeAttributes: everest.io/share-export-location: 192.168.0.169:/ storage.kubernetes.io/csiProvisionerIdentity: everest-csi-provisioner volumeHandle: 8962a2a2-a583-4b7f-bb74-fe76712d8414 persistentVolumeReclaimPolicy: Retain storageClassName: csi-sfsturboTable 1 Key parameters Parameter
Description
driver
Storage driver used to mount the volume. Set it to sfsturbo.csi.everest.io.
everest.io/share-export-location
Shared path of the SFS Turbo volume.
volumeHandle
SFS Turbo volume ID.
You can obtain the ID on the SFS Turbo storage instance details page on the SFS console.
persistentVolumeReclaimPolicy
The Delete and Retain policies are supported.
Delete: When a PVC is deleted, both the PV and the EVS disk 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-sfsturbo for SFS Turbo volumes.
spec.mountOptions
Mount options.
If this parameter is 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
The value is the same as the name of the PVC created in the next step.
spec.claimRef.namespace
The value is the same as the namespace of the PVC created in the next step.
spec.persistentVolumeReclaimPolicy
Reclaim policy of the PV.
- Delete: Both the PV and SFS Turbo file system are deleted when a PVC is deleted.
- Retain: Both the PV and SFS Turbo file system are not deleted when a PVC is deleted. The PV turns to the Released state and cannot be bound to a PVC again. You are advised to manually delete the PV in the Released state.
- vi pvc-sfsturbo-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-sfsturbo-example namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi storageClassName: csi-sfsturbo volumeName: pv-sfsturbo-exampleTable 2 Key parameters Parameter
Description
storageClassName
Name of the Kubernetes storage class. Set this field to csi-sfsturbo.
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.
- vi pv-sfsturbo-example.yaml
- Create the PV.
kubectl create -f pv-sfsturbo-example.yaml
- Create the PVC.
kubectl create -f pvc-sfsturbo-example.yaml
Last Article: Using SFS Turbo Volumes
Next Article: (kubectl) Creating a Deployment Mounted with an SFS Turbo Volume
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.