All Products
Search
Document Center

Container Compute Service:Mount a statically provisioned CPFS for LINGJUN volume

Last Updated:Dec 10, 2024

In AIGC and autonomous driving scenarios, you can use CPFS for LINGJUN to persist data. This topic describes how to mount a statically provisioned CPFS volume and verity that the volume can be used to share and persist data.

Background information

CPFS for LINGJUN is a file storage service with ultra-high performance developed by Alibaba Cloud. CPFS for LINGJUN provides end-to-end RDMA and can be used in intelligent computing scenarios such as AIGC and autonomous driving. For more information, see Overview of volumes.

Important

ACS supports only CPFS for LINGJUN. It does not support CPFS General-purpose Edition. CPFS for LINGJUN is in invitational preview. For more information, see CPFS for LINGJUN.

Prerequisites

The latest version of managed-csiprovisioner is installed in your Alibaba Cloud Container Compute Service (ACS) cluster.

Note

Go to the ACS cluster management page in the ACS console. In the left-side navigation pane of the cluster management page, choose Operations > Add-ons. On the Storage tab, you can check whether managed-csiprovisioner is installed.

Limits

  • You can mount CPFS for LINGJUN volumes to only GPU-accelerated workloads deployed in high-performance networks.

  • Only some regions and zones support CPFS for LINGJUN. For more information, see CPFS for LINGJUN.

Precautions

  • CPFS is a shared storage file system. A CPFS volume can be mounted to multiple pods.

  • CPFS for LINGJUN uses the pay-as-you-go billing method. For more information, see CPFS for LINGJUN.

Create a CPFS for LINGJUN file system

CPFS for LINGJUN is in invitational preview. To use it, you need to submit a ticket to apply to be added to the whiteslit. For more information, see Create a CPFS for LINGJUN file system.

Mount a statically provisioned CPFS volume

Step 1: Create a PVC

  1. Connect to your ACS cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster and Use kubectl on Cloud Shell to manage ACS clusters.

  2. Create a file named cpfs-pvc.yaml based on the following content.

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: cpfs-pvc
      annotations:
        csi.alibabacloud.com/mountpoint: bmcpfs-*****:/dir
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 20Gi
      storageClassName: alibaba-cloud-cpfs-premium

    The following table describes the parameters.

    Parameter

    Description

    csi.alibabacloud.com/mountpoint

    The directory of the CPFS file system to be mounted.

    • If you enter the ID of a CPFS for LINGJUN file system, such as bmcpfs-*****, the root directory (/) of the file system is mounted.

    • If you enter the ID of a CPFS for LINGJUN file system and a subdirectory, such as bmcpfs-*****:/dir, the directory (/dir) of the file system is mounted. If /dir does not exist, the system creates the directory.

    csi.alibabacloud.com/mount-options

    The mount parameters. We recommend that you use nolock,tcp,noresvport.

    accessModes

    The access mode.

    storage

    The storage space allocated to the pod, which is the size of the CPFS volume.

  3. Create a PVC.

    kubectl create -f cpfs-pvc.yaml

Step 2: Create an application and mount the CPFS volume

  1. Create a file named cpfs-test.yaml based on the following cotnent.

    The YAML file creates a Deployment of two pods. The two pods use alibabacloud.com/compute-class: gpu-hpn to request GPU compute power and use the cpfs-pvc PVC to request storage resources. The mount path is /data for both 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
            alibabacloud.com/compute-class: gpu-hpn
        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-pvc
  2. Create a Deployment and mount the CPFS volume.

    kubectl create -f cpfs-test.yaml
  3. View the status of the pods created by the Deployment.

    kubectl get pod | grep cpfs-test

    If the following output is returned, the pods are created.

    cpfs-test-****-***a   1/1     Running   0          45s
    cpfs-test-****-***b   1/1     Running   0          45s
  4. View the mount path.

    Run the following command. Data in the mount path of the CPFS for LINGJUN file system will be returned. By default, no data is returned.

    kubectl exec cpfs-test-****-***a -- ls /data

Verify shared storage and persistent storage

The CPFS for LINGJUN file system is mounted to the pods created by the Deployment. You can use the following method to verify it:

  • Create a file in one pod and view the file from the other pod in order to verify shared storage.

  • Recreate the Deployment. Then, check whether data stored in the file system exists from the newly created pod in order to verify persistent storage.

  1. View the pod information.

    kubectl get pod | grep cpfs-test

    Expected output:

    cpfs-test-****-***a   1/1     Running   0          45s
    cpfs-test-****-***b   1/1     Running   0          45s
  2. Verify shared storage.

    1. Create a file in the pod.

      The pod cpfs-test-****-***a is used as an example.

      kubectl exec cpfs-test-****-***a -- touch /data/test.txt
    2. View the file from the other pod.

      The pod cpfs-test-****-***b is used as an example.

      kubectl exec cpfs-test-****-***b -- ls /data

      The expected output is as follows. The file test.txt is shared.

      test.txt
  3. Verify persistent storage.

    1. Recreate the Deployment.

      kubectl rollout restart deploy cpfs-test
    2. Wait until the pods are recreated.

      kubectl get pod | grep cpfs-test

      Expected output:

      cpfs-test-****-***c   1/1     Running   0          78s
      cpfs-test-****-***d   1/1     Running   0          52s
    3. Check whether data stored in the file system exists from the newly created pod.

      The pod cpfs-test-c*** is used as an example.

      kubectl exec cpfs-test-****-***c -- ls /data

      The expected output is as follows. Data stored in the CPFS for LINGJUN file system can be obtained from the mount path of the pod.

      test.txt