Creating an SFS Subdirectory Using a Dynamic PV
When an SFS volume is mounted to a workload container, the root directory is mounted to the container by default. To properly use the storage capacity, CCE allows you to dynamically create an SFS subdirectory when creating a PVC so that different workloads can share one SFS volume.
Only SFS 3.0 supports dynamic creation of subdirectories.
Prerequisites
- You have created a cluster and installed the CCE Container Storage (Everest) add-on of v2.4.41 or later in the cluster.
- To create a cluster using commands, ensure kubectl is used. For details, see Connecting to a Cluster Using kubectl.
- You have created an available SFS file system, and the SFS file system and the cluster are in the same VPC. Before using SFS 3.0 for storage, ensure a VPC endpoint has been created in the VPC where the cluster is located for the cluster to access the SFS 3.0 file system. For details, see Configuring a VPC Endpoint.
Dynamically Creating an SFS Subdirectory on the Console
- Log in to the CCE console and click the cluster name to access the cluster console.
- Choose Storage in the navigation pane. In the right pane, click the PVCs tab. Click Create PVC in the upper right corner. In the dialog box displayed, configure PVC parameters.
Parameter
Description
PVC Type
In this example, select SFS.
PVC Name
Enter the PVC name, which must be unique in a namespace.
Creation Method
Select New subdirectory.
Storage Classes
Select csi-sfs for SFS.
You can customize a StorageClass and configure its reclaim policy and binding mode. For details, see Creating a StorageClass Using the CCE Console.
Access Mode
SFS volumes support only ReadWriteMany, indicating that a storage volume can be mounted to multiple nodes in read/write mode. For details, see Volume Access Modes.
File Storage
Click Select SFS. On the displayed page, select the SFS file system that meets your requirements and click OK.
Subdirectory
Enter the absolute path of a subdirectory, for example, /a/b.
Subdirectory Reclaim Policy
Whether to retain subdirectories when a PVC is deleted.
- Retain: If a PVC is deleted, the PV will be deleted, but the subdirectories associated with the PV will be retained.
- Delete: After a PVC is deleted, the PV and its associated subdirectories will also be deleted.
NOTE:
When a subdirectory is deleted, only the absolute path of the subdirectory configured in the PVC will be deleted. The upper-layer directory will not be deleted.
- Click Create to create a PVC and a PV.
You can choose Storage in the navigation pane and view the created PVC and PV on the PVCs and PVs tab pages, respectively.
Dynamically Creating an SFS Subdirectory Using kubectl
- Use kubectl to access the cluster.
- Create the pvc-sfs-subpath.yaml file.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-sfs-subpath # PVC name namespace: default annotations: everest.io/csi.volume-as: absolute-path # An SFS subdirectory is used. everest.io/csi.sfs30-name: <sfs_name> # Name of the SFS instance everest.io/csi.path: /a # Subdirectory that is automatically created, which must be an absolute path everest.io/csi.reclaim-policy: retain-volume-only # When a PVC is deleted, the PV will be deleted, but the subdirectories associated with the PV will be retained. spec: accessModes: - ReadWriteMany # ReadWriteMany must be selected for SFS. resources: requests: storage: 1Gi # This parameter is only used for verification for the PVCs of the SFS subdirectory type. The value cannot be empty or 0. storageClassName: csi-sfs # StorageClass name of SFS 3.0
Table 1 Key parameters Parameter
Mandatory
Description
everest.io/csi.volume-as
Yes
When a dynamically created SFS subdirectory is used, the value of this parameter is consistently absolute-path.
everest.io/csi.sfs30-name
Yes
SFS instance name.
everest.io/csi.path
Yes
Subdirectory that is automatically created, which must be an absolute path.
everest.io/csi.reclaim-policy
Yes
Whether to retain subdirectories when deleting a PVC. This parameter must be used with PV Reclaim Policy. This parameter is available only when the PV reclaim policy is Delete. Options:
- retain-volume-only: If a PVC is deleted, the PV will be deleted, but the subdirectories associated with the PV will be retained.
- delete: After a PVC is deleted, the PV and its associated subdirectories will also be deleted.
NOTE:
When a subdirectory is deleted, only the absolute path of the subdirectory configured in the PVC will be deleted. The upper-layer directory will not be deleted.
storage
Yes
Requested capacity in the PVC, in Gi.
This parameter is only used for verification for the PVCs of the SFS subdirectory type. The value cannot be empty or 0, and can be fixed at 1 because any value you set does not take effect.
- Run the following command to create a PVC:
kubectl apply -f pvc-sfs-subpath.yaml
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot