CPFS is a fully managed, scalable parallel file system by Alibaba Cloud for high-performance computing. It supports concurrent access from hundreds to thousands of servers, delivering tens of GB/s of throughput, millions of IOPS, and sub-millisecond latency. This topic describes how to mount a statically provisioned CPFS volume to an application and verify that the volume can share and persist data.
Features
CPFS is available in two editions: CPFS General-purpose Edition and CPFS for LINGJUN. Choose the edition that best suits your business scenario and performance requirements. See CPFS product overview for a comparison of the use cases and differences between the two editions.
Before you begin, note the following:
-
CPFS for LINGJUN, which supports end-to-end RDMA networks, is in invitational preview and available only in specific regions and zones.
-
When you access CPFS for LINGJUN over an RDMA network, the hpn-zone of the pod must match the hpn-zone of CPFS for LINGJUN.
-
CPFS is shared storage. A CPFS volume can be mounted to multiple pods.
-
The following table describes CPFS support for different types of ACS pods.
Edition
Access method
CPU type
GPU type
CPFS General-purpose Edition
VPC network
Supported
Supported
CPFS for LINGJUN
VPC network
Supported
Supported
RDMA network
Not supported
Only specific GPU models are supported. For a list of RDMA-supported GPU models, see GPU models supported by ACS.
Prerequisites
The managed-csiprovisioner component is installed in the ACS cluster.
Go to the ACS cluster management page in the ACS console. In the left-side navigation pane of the cluster management page, choose . On the Storage tab, you can check whether managed-csiprovisioner is installed.
Create a CPFS file system
CPFS General-purpose
-
Create a CPFS General-purpose Edition file system.
After creating the file system, record its ID.
-
Use the VPC and vSwitch of your ACS cluster to create a protocol service and generate a directory-level mount target. After you create the protocol service, record the mount target domain name for the exported directory in the format
cpfs-***-***.<Region>.cpfs.aliyuncs.com.In the left-side navigation pane of the file system details page, click Protocol Service. On the exported directories page, click the Copy icon next to the mount address. This action copies the mount target domain name.
CPFS for LINGJUN
-
Create a CPFS for LINGJUN file system.
After creating the file system, record its ID.
-
(Optional) Create a VPC mount target.
-
Pods that do not support the RDMA protocol (such as CPU pods and some GPU pods) require a VPC mount target to access CPFS over the VPC network.
Use the VPC and vSwitch of your ACS cluster to create a VPC mount target and generate a mount address. After you create the VPC mount target, record the mount target domain name in the format
cpfs-***-vpc-***.<Region>.cpfs.aliyuncs.com.In the left-side navigation pane of the file system details page, click Mounting. On the Mount Target tab, find the VPC mount target that you created. Click the View Details icon next to the mount address to view and copy the complete mount address.
-
Mount CPFS volumes
Step 1: Create a PV and a PVC
Kubectl
-
Save the following YAML content as cpfs-pv-pvc.yaml.
Select the appropriate YAML manifest based on the CPFS edition you use and the compute type of the pod.
CPFS general-purpose edition
apiVersion: v1 kind: PersistentVolume metadata: name: cpfs-test labels: alicloud-pvname: cpfs-test spec: accessModes: - ReadWriteMany capacity: storage: 10Ti csi: driver: nasplugin.csi.alibabacloud.com volumeAttributes: mountProtocol: cpfs-nfs server: cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.com path: /share volumeHandle: cpfs-***** --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cpfs-test spec: accessModes: - ReadWriteMany selector: matchLabels: alicloud-pvname: cpfs-test resources: requests: storage: 10Ti-
PersistentVolume parameters
Parameter
Description
labelsThe labels for the PersistentVolume. A PersistentVolumeClaim uses a
selectorto bind to a PersistentVolume by matching these labels.accessModesThe access mode of the PersistentVolume.
capacity.storageThe capacity of the volume.
csi.driverThe CSI driver. Set the value to
nasplugin.csi.alibabacloud.com.csi.volumeAttributesThe attributes of the CPFS volume.
-
mountProtocol: Set the value tocpfs-nfs. -
server: The mount target domain name of the CPFS General-purpose Edition file system. -
path: The directory path within the CPFS file system to mount, such as/share. You can also specify a subdirectory, such as/share/dir.
csi.volumeHandleThe ID of the CPFS General-purpose Edition file system.
-
-
PersistentVolumeClaim parameters
Parameter
Description
accessModesThe access mode requested by the PersistentVolumeClaim.
selectorThe selector used to find a matching PersistentVolume based on labels.
resources.requests.storageThe amount of storage requested by the PersistentVolumeClaim. The value cannot exceed the capacity of the PersistentVolume.
CPFS for LINGJUN (RDMA network)
ImportantYou can mount the volume only to pods with specific GPU models. For more information about the GPU models that support the RDMA protocol, see GPU models supported by ACK.
apiVersion: v1 kind: PersistentVolume metadata: name: cpfs-test labels: alicloud-pvname: cpfs-test spec: accessModes: - ReadWriteMany capacity: storage: 10Ti csi: driver: bmcpfsplugin.csi.alibabacloud.com volumeAttributes: filesystemId: bmcpfs-***** path: / volumeHandle: bmcpfs-***** --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cpfs-test spec: accessModes: - ReadWriteMany selector: matchLabels: alicloud-pvname: cpfs-test resources: requests: storage: 10Ti-
PersistentVolume parameters
Parameter
Description
labelsThe labels for the PersistentVolume. A PersistentVolumeClaim uses a
selectorto bind to a PersistentVolume by matching these labels.accessModesThe access mode of the PersistentVolume.
capacity.storageThe capacity of the volume.
csi.driverThe CSI driver. Set the value to
bmcpfsplugin.csi.alibabacloud.com.csi.volumeAttributesThe attributes of the CPFS volume.
-
filesystemId: The ID of the CPFS for LINGJUN file system. -
path: The directory to mount. The default value is/, which indicates the root directory of the CPFS file system. You can also specify a subdirectory, such as/dir. If the subdirectory does not exist, it is automatically created on mount.
csi.volumeHandleThe ID of the CPFS for LINGJUN file system.
-
-
PersistentVolumeClaim parameters
Parameter
Description
accessModesThe access mode requested by the PersistentVolumeClaim.
selectorThe selector used to find a matching PersistentVolume based on labels.
resources.requests.storageThe amount of storage requested by the PersistentVolumeClaim. The value cannot exceed the capacity of the PersistentVolume.
CPFS for LINGJUN (VPC network)
apiVersion: v1 kind: PersistentVolume metadata: name: cpfs-test labels: alicloud-pvname: cpfs-test spec: accessModes: - ReadWriteMany capacity: storage: 10Ti csi: driver: nasplugin.csi.alibabacloud.com volumeAttributes: mountProtocol: efc server: cpfs-***-vpc-***.cn-wulanchabu.cpfs.aliyuncs.com path: / volumeHandle: bmcpfs-***** --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cpfs-test spec: accessModes: - ReadWriteMany selector: matchLabels: alicloud-pvname: cpfs-test resources: requests: storage: 10Ti-
PersistentVolume parameters
Parameter
Description
labelsThe labels for the PersistentVolume. A PersistentVolumeClaim uses a
selectorto bind to a PersistentVolume by matching these labels.accessModesThe access mode of the PersistentVolume.
capacity.storageThe capacity of the volume.
csi.driverThe CSI driver. Set the value to
nasplugin.csi.alibabacloud.com.csi.volumeAttributesThe attributes of the CPFS volume.
-
mountProtocol: The mount protocol. Set the value toefc. -
server: The VPC mount target domain name of the CPFS file system. -
path: The directory to mount. The default value is/, which indicates the root directory of the CPFS file system. You can also specify a subdirectory, such as/dir. If the subdirectory does not exist, it is automatically created on mount.
csi.volumeHandleThe ID of the CPFS for LINGJUN file system.
-
-
PersistentVolumeClaim parameters
Parameter
Description
accessModesThe access mode requested by the PersistentVolumeClaim.
selectorThe selector used to find a matching PersistentVolume based on labels.
resources.requests.storageThe amount of storage requested by the PersistentVolumeClaim. The value cannot exceed the capacity of the PersistentVolume.
-
-
Create the PersistentVolume and PersistentVolumeClaim.
kubectl create -f cpfs-pv-pvc.yaml -
Verify that the PersistentVolumeClaim is bound to the PersistentVolume.
kubectl get pvc cpfs-testThe following output shows that the PersistentVolumeClaim is bound.
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE cpfs-test Bound cpfs-test 10Ti RWX <unset> <unset> 10s
Console
Log on to the ACS console.
On the Clusters, click the name of the cluster to go to the cluster management page.
In the left-side navigation pane of the cluster management page, choose .
On the Persistent Volume Claims page, click Create.
-
In the dialog box that appears, configure the parameters and click Create.
The following table describes the parameters for creating a PersistentVolumeClaim and a PersistentVolume at the same time. Alternatively, you can create a PersistentVolume first and then create a PersistentVolumeClaim.
NoteWhen you use the console, you cannot mount a CPFS for LINGJUN file system to a CPU application by using a VPC mount target.
Parameter
Description
Example
PVC Type
Select CPFS.
CPFS
Name
The name of the PersistentVolumeClaim. It must comply with the format requirements displayed on the page.
cpfs-test
Allocation Mode
Select Existing Volumes or Create PV as needed.
Create PV
CPFS Type
Select CPFS for LINGJUN or CPFS General-purpose as needed.
CPFS for LINGJUN
Access Mode
Specifies the access mode. Supported modes include ReadWriteMany and ReadWriteOnce.
ReadWriteMany
Mount Target Domain Name:
For CPFS General-purpose Edition, specify the mount target domain name. You can also specify a subdirectory.
-
If you enter only the mount target domain name, such as
cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.com, the root directory (/) of the CPFS file system is mounted. -
If you enter the mount target domain name and a subdirectory, such as
cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.com:/dir, the system mounts the/dirsubdirectory of the CPFS file system. If the/dirsubdirectory does not exist, the system automatically creates it.
cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.comFile System ID:
If you use CPFS for LINGJUN, specify the ID of the file system to mount.
bmcpfs-0115******13q5
-
-
View the created PersistentVolume and PersistentVolumeClaim.
On the Persistent Volume Claims page and the Persistent Volumes page, find the newly created PersistentVolumeClaim and PersistentVolume and verify that their status is Bound.
Step 2: Create an application and mount CPFS
kubectl
-
Create a file named
cpfs-test.yamlwith the following content.GPU application
The following YAML example creates a Deployment with two Pods. Both Pods use the
alibabacloud.com/compute-class: gpulabel to request GPU-based computing power and a PersistentVolumeClaim (PVC) namedcpfs-testto request storage resources. The mount path for both Pods is/data.NoteFor more information about specific GPU models, see Specify GPU models and driver versions for ACS GPU Pods.
apiVersion: apps/v1 kind: Deployment metadata: name: cpfs-test labels: app: cpfs-test spec: replicas: 2 selector: matchLabels: app: cpfs-test template: metadata: labels: app: cpfs-test # Specify the compute type as GPU. alibabacloud.com/compute-class: gpu # Specify the GPU model, for example, T4. alibabacloud.com/gpu-model-series: T4 alibabacloud.com/compute-qos: default spec: containers: - name: nginx image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest ports: - containerPort: 80 volumeMounts: - name: pvc-cpfs mountPath: /data volumes: - name: pvc-cpfs persistentVolumeClaim: claimName: cpfs-testCPU application
The following YAML example creates a Deployment with 2 pods, which request storage resources by using a PVC named
cpfs-testand are both mounted to the/datapath.apiVersion: apps/v1 kind: Deployment metadata: name: cpfs-test labels: app: cpfs-test spec: replicas: 2 selector: matchLabels: app: cpfs-test template: metadata: labels: app: cpfs-test spec: containers: - name: nginx image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest ports: - containerPort: 80 volumeMounts: - name: pvc-cpfs mountPath: /data volumes: - name: pvc-cpfs persistentVolumeClaim: claimName: cpfs-test -
Create the Deployment and mount the CPFS volume.
kubectl create -f cpfs-test.yaml -
Check the status of the Pods in the Deployment.
kubectl get pod | grep cpfs-testThe expected output shows that two Pods are in the 'Running' state.
cpfs-test-****-***a 1/1 Running 0 45s cpfs-test-****-***b 1/1 Running 0 45s -
Check the mount path.
This command lists the contents of the mounted directory (/data), which contains data from the CPFS for LINGJUN file system. The directory is empty by default.
kubectl exec cpfs-test-****-***a -- ls /data
Console
In the left-side navigation pane of the cluster management page, choose .
-
On the Deployments page, click Create from Image.
-
Configure the parameters for the Deployment and click Create.
The key parameters are described below. You can keep the default values for other parameters. For more information, see Create a stateless application by using a Deployment.
GPU application
Section
Parameter
Description
Example
Basic Information
Application Name
Enter a unique name for the Deployment. The name must conform to the format requirements shown on the page.
cpfs-test
Replicas:
The number of Pod replicas for the Deployment.
2
Instance Type
Specifies the hardware resources for the Pods, such as CPU or a specific GPU model.
NoteFor more information about specific GPU models, see Specify GPU models and driver versions for ACS GPU Pods.
GPU, T4
Container
Image Name
The container image used to deploy the application.
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
Required Resources
The amount of GPU, vCPU, and memory resources to allocate to each Pod.
-
GPU: 1
-
CPU: 2 vCPU
-
Memory: 2 GiB
Volume
Click Add PVC and then configure the parameters.
-
Mount Source: Select the existing PersistentVolumeClaim.
-
Container Path: Enter the path within the container where the CPFS file system will be mounted.
-
Mount source: pvc-cpfs
-
Container path: /data
CPU application
Section
Parameter
Description
Example
Basic Information
Application Name
Enter a unique name for the Deployment. The name must conform to the format requirements shown on the page.
cpfs-test
Replicas:
The number of Pod replicas for the Deployment.
2
Instance Type
The compute type of the Pod.
CPU, General Purpose
Container
Image Name
The container image used to deploy the application.
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
Required Resources
The amount of vCPU and memory resources to allocate to each Pod.
-
CPU: 0.25 vCPU
-
Memory: 0.5 GiB
Volume
Click Add PVC and then configure the parameters.
-
Mount Source: Select the existing PersistentVolumeClaim.
-
Container Path: Enter the path within the container where the CPFS file system will be mounted.
-
Mount source: pvc-cpfs
-
Container path: /data
-
-
Check the application's status.
-
On the Deployments page, click the application name.
-
On the Pods tab, check that the Pods are in the 'Running' state.
-
Verify CPFS shared and persistent storage
The Deployment created in the previous example contains two Pods, both of which mount the same CPFS file system. You can verify its shared storage and persistent storage as follows:
-
Verify shared storage by creating a file in one Pod and then checking for it in the other Pod.
-
Verify persistent storage by restarting the Deployment and then checking if the data persists in the newly created Pods.
-
Check the Pods.
kubectl get pod | grep cpfs-testExample output:
cpfs-test-****-***a 1/1 Running 0 45s cpfs-test-****-***b 1/1 Running 0 45s -
Verify shared storage.
-
Create a file in one of the Pods.
This example uses the Pod named
cpfs-test-****-***a:kubectl exec cpfs-test-****-***a -- touch /data/test.txt -
Check for the file in the other Pod.
This example uses the Pod named
cpfs-test-****-***b:kubectl exec cpfs-test-****-***b -- ls /dataThe output,
test.txt, confirms that storage is shared.test.txt
-
-
Verify persistent storage.
-
Restart the Deployment.
kubectl rollout restart deploy cpfs-test -
Check the Pod status and wait for the new Pods to be created.
kubectl get pod | grep cpfs-testExample output:
cpfs-test-****-***c 1/1 Running 0 78s cpfs-test-****-***d 1/1 Running 0 52s -
Verify that the data persists in the new Pod.
This example uses the Pod named
cpfs-test-****-***c:kubectl exec cpfs-test-****-***c -- ls /dataThis output confirms that data on the CPFS file system persists and is accessible from the new Pod's mount directory.
test.txt
-