Use CPFS static volumes
Cloud Parallel File Storage (CPFS) is a fully managed parallel file system for high-performance computing (HPC) scenarios that supports on-demand extension. CPFS supports concurrent access from hundreds to thousands of machines, with tens of GB of throughput, millions of IOPS, and sub-millisecond latency. Mount a CPFS static volume to an ACS pod to provide your applications with shared, persistent, high-performance storage.
Usage notes
CPFS provides two editions: general-purpose CPFS and CPFS for Lingjun. Select an edition based on your business scenario and storage performance requirements. For the common scenarios and the differences between the two editions, see CPFS product overview.
Before you mount a volume, note the following items:
Invitational preview: CPFS for Lingjun supports end-to-end Remote Direct Memory Access (RDMA) networks. This edition is available only in specific regions and zones.
RDMA network requirement: When you access CPFS for Lingjun over an RDMA network, the pod and the file system must be in the same hpn-zone.
Shared storage: One CPFS volume can be mounted to multiple pods.
Supported compute classes: The following table lists the ACS pod compute classes that CPFS supports.
Specification | Access method | CPU type | GPU type |
General-purpose CPFS | Virtual Private Cloud (VPC) | Supported | Supported |
CPFS for Lingjun | VPC | Supported | Supported |
RDMA | Not supported | Supported by specific GPU models. For the GPU models that support the RDMA protocol, see Supported GPU types |
Prerequisites
The managed-csiprovisioner add-on is installed in the ACS cluster.
Go to the ACS cluster management page in the ACS console. In the left-side navigation pane, click Components and Add-ons. On the Storage tab, verify that managed-csiprovisioner is installed.
Create a CPFS file system
General-purpose CPFS
Create a general-purpose CPFS file system.
After the file system is created, record the file system ID.
Use the VPC and the vSwitch of the ACS cluster to create the Protocol Service and generate a directory-level mount target. After the Protocol Service is created, record the mount target domain name of the export directory. The domain name is in the
cpfs-***-***.<Region>.cpfs.aliyuncs.comformat.On the file system details page, click Protocol Service in the left-side navigation pane. On the export directory list page, click the copy icon to the right of the mount address to copy the mount target domain name.
CPFS for Lingjun
Create a CPFS for Lingjun file system.
After the file system is created, record the file system ID.
(Optional) Create a VPC mount target.
For pods that do not support the RDMA protocol, such as CPU pods and some GPU pods, create a VPC mount target to access CPFS over the VPC.
Use the Virtual Private Cloud (VPC) and the vSwitch of the ACS cluster to create the VPC mount target and generate a mount address. After the mount target is created, record the mount target domain name. The domain name is in the
cpfs-***-vpc-***.<Region>.cpfs.aliyuncs.comformat.On the file system details page, click Mounting in the left-side navigation pane. On the Mount Target tab, find the VPC mount target that you created. Click the view details icon to the right of the mount address to get the complete mount address and copy it.
Mount a CPFS volume
Step 1: Create a PV and a PVC
kubectl
Save the following YAML content to a file named
cpfs-pv-pvc.yaml.Select the YAML content based on the CPFS edition that you use. Also select the YAML based on the compute class of the pods to be mounted.
General-purpose CPFS
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: 10TiPV parameters:
Parameter
Description
labelsSets a label so that the PVC can use
selectorto match and bind the PV.accessModesThe access mode of the PV.
capacity.storageThe declared capacity of the volume.
csi.driverThe driver type. Set the value to
nasplugin.csi.alibabacloud.com.csi.volumeAttributesThe attributes of the CPFS volume. Set
mountProtocoltocpfs-nfs. Setserverto the mount target domain name of the export directory of the general-purpose CPFS Protocol Service. Setpathto the path of the export directory of the general-purpose CPFS Protocol Service, such as/share. Optionally, specify a subdirectory, such as/share/dir.csi.volumeHandleThe ID of the general-purpose CPFS file system.
PVC parameters:
Parameter
Description
accessModesThe access mode that the PVC requests from the PV.
selectorMatches and binds the PV based on the label on the PV.
resources.requests.storageThe storage capacity allocated to the pod. The value must not exceed the capacity of the PV.
CPFS for Lingjun
ImportantCPFS for Lingjun can be mounted only to pods of specific GPU models. For the GPU models that support the RDMA protocol, see Supported GPU types.
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: mountpointAutoSwitch: "true" # Enables automatic switchover between the RDMA mount address and the VPC mount address vpcMountTarget: cpfs-***-vpc-***.<Region>.cpfs.aliyuncs.com 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: 10TiPV parameters:
Parameter
Description
labelsSets a label so that the PVC can use
selectorto match and bind the PV.accessModesThe access mode of the PV.
capacity.storageThe declared capacity of the volume.
csi.driverThe driver type. 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 default value/mounts the root directory of the CPFS file system. Optionally, specify a subdirectory, such as/dir. If the subdirectory does not exist, it is automatically created when the volume is mounted.csi.volumeHandleThe ID of the CPFS for Lingjun file system.
PVC parameters:
Parameter
Description
accessModesThe access mode that the PVC requests from the PV.
selectorMatches and binds the PV based on the label on the PV.
resources.requests.storageThe storage capacity allocated to the pod. The value must not exceed the capacity of the PV.
Create the PV and the PVC.
kubectl create -f cpfs-pv-pvc.yamlVerify that the PVC is bound to the PV.
kubectl get pvc cpfs-testThe following output is returned:
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 page, 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 Volumes > Persistent Volume Claims.
On the Persistent Volume Claims page, click Create.
In the dialog box that appears, configure the parameters and then click Create.
The following table describes the parameters for creating a PV together with a PVC. Alternatively, create the PV first and then create the PVC.
NoteIn the console, mounting CPFS for Lingjun for CPU applications through a VPC mount target is currently not supported.
Parameter
Description
Example
PVC Type
Select CPFS.
CPFS
Name
The name of the PVC. Enter a custom name. For the format requirements, see the tips on the page.
cpfs-test
Allocation Mode
Select Existing Volumes or Create PV based on your requirements.
Create PV
CPFS Type
Select CPFS for LINGJUN or CPFS General-purpose based on your requirements. Select .
CPFS for LINGJUN
Access Mode
Both ReadWriteMany and ReadWriteOnce are supported.
ReadWriteMany
Mount Target Domain Name:
If you use general-purpose CPFS, specify the CPFS file system directory that you want to mount. If you enter only the mount address, such as
cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.com, the root directory (/) of the CPFS file system is mounted. If you enter the mount address and a subdirectory, such ascpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.com:/dir, the/dirdirectory of the CPFS file system is mounted. If the/dirdirectory does not exist, it is automatically created.cpfs-***-***.cn-wulanchabu.cpfs.aliyuncs.comFile System ID:
If you use CPFS for Lingjun, specify the ID of the CPFS for Lingjun file system that you want to mount.
bmcpfs-0115******13q5View the PVC and the PV that you created.
On the Persistent Volume Claims page and the Persistent Volumes page, the new PVC and PV appear. Verify that they are bound.
Step 2: Create an application and mount CPFS
kubectl
Save the following YAML content to a file named
cpfs-test.yaml.GPU application
The following YAML example creates a Deployment that contains two pods. Both pods use the
alibabacloud.com/compute-class: gpulabel to declare that GPU computing power is required, request storage resources through the PVC namedcpfs-test, and mount the volume to the/datapath.NoteFor the specific GPU models, see Specify GPU models and driver versions for ACS GPU-accelerated 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 # Specifies the GPU compute class alibabacloud.com/compute-class: gpu # Specifies the GPU model. Set this value based on your actual model, such as 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 that contains two pods. The pods request storage resources through the PVC named
cpfs-testand mount the volume 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-testCreate the Deployment and mount CPFS.
kubectl create -f cpfs-test.yamlCheck the status of the pods in the Deployment.
kubectl get pod | grep cpfs-testThe following output is returned. Two pods are created.
cpfs-test-****-***a 1/1 Running 0 45s cpfs-test-****-***b 1/1 Running 0 45sView the mount path.
The following command is an example. It lists the contents of the mount directory of the CPFS file system. For a new file system, the directory is empty by default, and no output is returned.
kubectl exec cpfs-test-****-***a -- ls /data
Console
In the left-side navigation pane of the cluster management page, choose Workloads > Deployments.
On the Deployments page, click Create from Image.
Configure the Deployment parameters and click Create.
The following tables describe the parameters that require your attention. Use the default values for the other parameters. For more information, see Create a stateless workload Deployment.
GPU application
Configuration page
Parameter
Description
Example
Basic Information
Application Name
The name of the Deployment. Enter a custom name. For the format requirements, see the tips on the page.
cpfs-test
Replicas:
The number of replicas of the Deployment.
2
Instance Type
Select the compute class of the pods.
NoteFor the specific GPU models, see Specify GPU models and driver versions for ACS GPU-accelerated pods.
GPU, T4
Container
Image Name
Enter the address of the image used to deploy the application.
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
Required Resources
Set the required GPU, vCPU, and memory resources.
GPU: 1. CPU: 2 vCPUs. Memory: 2 GiB.
Volume
Click Add PVC and configure the parameters. Mount Source: select the PVC that you created. Container Path: enter the container path to which you want to mount the CPFS file system.
Mount Source: pvc-cpfs. Container Path: /data
CPU application
Configuration page
Parameter
Description
Example
Basic Information
Application Name
The name of the Deployment. Enter a custom name. For the format requirements, see the tips on the page.
cpfs-test
Replicas:
The number of replicas of the Deployment.
2
Instance Type
Select the compute class of the pods.
CPU, general-purpose
Container
Image Name
Enter the address of the image used to deploy the application.
registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
Required Resources
Set the required vCPU and memory resources.
CPU: 0.25 vCPUs. Memory: 0.5 GiB.
Volume
Click Add PVC and configure the parameters. Mount Source: select the PVC that you created. Container Path: enter the container path to which you want to mount the CPFS file system.
Mount Source: pvc-cpfs. Container Path: /data
Check the status of the application.
On the Deployments page, click the application name.
On the Pods tab, verify that the pods are running. The status is Running.
Verify the shared storage and persistent storage of CPFS
The Deployment created in the preceding example contains two pods that mount the same CPFS file system. Verify the storage capabilities in the following ways:
Create a file in one pod and then view the file in the other pod to verify shared storage.
Restart the Deployment and then check whether the data in the file system still exists in the new pods to verify persistent storage.
View the pod information.
kubectl get pod | grep cpfs-testThe following output is returned:
cpfs-test-****-***a 1/1 Running 0 45s cpfs-test-****-***b 1/1 Running 0 45sVerify shared storage.
Create a file in one pod.
The following example uses the pod named
cpfs-test-****-***a:kubectl exec cpfs-test-****-***a -- touch /data/test.txtView the file in the other pod.
The following example uses the pod named
cpfs-test-****-***b:kubectl exec cpfs-test-****-***b -- ls /dataThe following output is returned. The new file
test.txtis shared.test.txtVerify persistent storage.
Restart the Deployment to recreate its pods.
kubectl rollout restart deploy cpfs-testView the pods and wait until the new pods are created.
kubectl get pod | grep cpfs-testThe following output is returned:
cpfs-test-****-***c 1/1 Running 0 78s cpfs-test-****-***d 1/1 Running 0 52sCheck whether the data in the file system still exists in a new pod.
The following example uses the pod named
cpfs-test-****-***c:kubectl exec cpfs-test-****-***c -- ls /dataThe following output is returned. The data in the CPFS file system still exists and is available in the mount directory of the new pod.
test.txt