All Products
Search
Document Center

Container Service for Kubernetes:Use static volumes with CPFS General-purpose Edition

Last Updated:Oct 13, 2026

Cloud Parallel File Storage (CPFS) is a high-throughput, high-IOPS parallel file system for high-performance computing (HPC) use cases such as AI training and autonomous driving. In an ACK cluster, multiple Pods can mount the same CPFS General-purpose Edition static volume to achieve high-performance data sharing and persistent storage.

How it works

The following workflow describes how to mount a CPFS General-purpose Edition static volume in an ACK cluster.

image
  1. Create a Persistent Volume (PV): Register an existing CPFS General-purpose Edition file system in the cluster and declare its mount target, capacity, access mode, and other settings.

  2. Create a Persistent Volume Claim (PVC): An application uses a PVC to request the registered storage resource. The PVC automatically binds to a matching PV.

  3. Mount the volume in an application: Mount the bound PVC to an application Pod as a persistent directory in the container.

Prerequisites

  • Check and upgrade the CSI add-ons: Ensure that the csi-plugin and csi-provisioner add-ons are version v1.22.11-abbb810e-aliyun or later.

    For upgrade instructions, see Upgrade CSI components.
  • Configure the storage add-on to support CPFS mounting.

    Configuration procedure

    Choose a configuration method based on the csi-plugin version.

    1.33 and later

    Install the cnfs-nas-daemon add-on and configure csi-plugin to enable the AlinasMountProxy=true feature gate. CSI then calls cnfs-nas-daemon to mount the volume. For more information, see Manage the cnfs-nas-daemon add-on.

    Earlier than 1.33

    1. Configure a ConfigMap to enable the NFS protocol used to mount CPFS General-purpose Edition.

      cat << EOF | kubectl apply -f -
      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: csi-plugin
        namespace: kube-system
      data:
        cpfs-nas-enable: "true"   # Use the NFS protocol to mount CPFS General-purpose Edition.
      EOF
    2. Restart csi-plugin to install the required dependencies.

      This operation does not affect your running workloads.

      kubectl -n kube-system rollout restart daemonset csi-plugin

      Expected output:

      daemonset.apps/csi-plugin restarted
  • Prepare a CPFS General-purpose Edition file system, a Protocol Service, and a mount target that the ACK cluster can mount.

    If you have not created these resources, in the region where the cluster is deployed, create a CPFS General-purpose Edition file system. Use the VPC and vSwitch of the cluster to create a Protocol Service, and then generate a mount target.

    • File system: The file system must be in the same region as the cluster, run version 2.3.0 or later, and be deployed in a region where CPFS General-purpose Edition is available.

      In the NAS console, on the File System List page, click the target CPFS file system. On the Basic Information page, verify the CPFS version.
    • Protocol Service: CPFS does not support cross-VPC mounting. The VPC that you use must be the same as the VPC of the cluster.

    • Obtain the mount target of the Protocol Service, which consists of a mount target domain name and an export directory. If you specify the export directory / , the mount target is cpfs-****.<Region ID>.cpfs.aliyuncs.com:/share.

      On the Protocol Service page, click Export Directory, and then copy and save the mount target from the Mount address column.
  • Understand the Limits for CPFS General-purpose Edition.

Step 1: Create a PV

Create a PV in the cluster to register an existing CPFS file system.

  1. Save the following content as cpfs-pv.yaml.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: cpfs-pv
      labels:  # Define labels for subsequent PVC binding
        alicloud-pvname: cpfs-pv
    spec:
      accessModes:  # Access mode
      - ReadWriteMany
      capacity:
        storage: 20Gi  # Define the total capacity of the PV
      csi:
        driver: nasplugin.csi.alibabacloud.com  # Use this fixed value
        volumeAttributes:
          mountProtocol: cpfs-nfs   # Use the NFS protocol to mount CPFS
          path: "/share"    # The mount directory in the mount target
          volumeAs: subpath    # Subdirectory
          server: "cpfs-******-******.cn-shanghai.cpfs.aliyuncs.com" # The mount target domain name in the mount target
        volumeHandle: cpfs-pv  # The unique identifier (UID) of the volume, which must match metadata.name       
      mountOptions:  # NFS mount options
      - rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport
      - vers=3

    Key parameters:

    Parameter

    Description

    accessModes

    The access mode of the PV.

    capacity.storage

    The declared volume capacity.

    csi.driver

    The driver type. For CPFS General-purpose Edition, this value is fixed as nasplugin.csi.alibabacloud.com.

    csi.volumeAttributes.server

    The mount target domain name in the mount target of the CPFS General-purpose Edition Protocol Service export directory.

    csi.volumeAttributes.path

    The mount directory in the mount target of the CPFS General-purpose Edition Protocol Service export directory, for example, /share. You can set a subdirectory, for example, /share/dir.

    csi.volumeAttributes.mountProtocol

    cpfs-nfs indicates that CPFS is mounted by using the NFS protocol.

    csi.volumeAttributes.volumeAs

    subpath indicates that a subdirectory-type PV is created.

    csi.volumeHandle

    The value must match the PV name.

  2. Run the following command to create the PV.

    kubectl apply -f cpfs-pv.yaml
  3. View the PV status.

    kubectl get pv cpfs-pv

    Expected output:

    NAME      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
    cpfs-pv   20Gi       RWX            Retain           Available                                   2s

Step 2: Create a PVC

Create a PVC to request the storage resource registered in the preceding step.

  1. Save the following content as cpfs-pvc.yaml.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: cpfs-pvc
    spec:
      accessModes:
      - ReadWriteMany  # Access mode
      resources:
        requests: 
          storage: 20Gi  # Requested storage capacity
      selector:  # 
        matchLabels:
          alicloud-pvname: cpfs-pv  # Bind exactly to the previously created PV

    Parameter

    Description

    accessModes

    The access mode that the PVC requests from the PV.

    selector

    Binds to the PV by matching its label.

    resources.requests.storage

    The storage capacity allocated to the Pod. The value must not exceed the PV capacity.

  2. Create the PVC.

    kubectl apply -f cpfs-pvc.yaml
  3. View the PVC status and verify that the PVC is bound to the PV.

    kubectl get pvc cpfs-pvc

    Example output:

    NAME       STATUS   VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
    cpfs-pvc   Bound    cpfs-pv   20Gi       RWO                           <unset>                 18m

Step 3: Create an application and mount the volume

Create an application workload and declare the previously created PVC in its configuration.

  1. Save the following content as cpfs-test.yaml.

    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: cpfs-sts
    spec:
      selector:
        matchLabels:
          app: nginx
      serviceName: "nginx"
      replicas: 2
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
            volumeMounts:
            - name: cpfs-pvc
              mountPath: /data  # Mount the volume to the /data directory in the container
          volumes:
          - name: cpfs-pvc
            persistentVolumeClaim:
              claimName: cpfs-pvc  # Reference the previously created PVC
  2. Create the StatefulSet.

    kubectl apply -f cpfs-test.yaml
  3. View the Pod status.

    kubectl get pods -l app=nginx

    Expected output:

    NAME         READY   STATUS    RESTARTS   AGE
    cpfs-sts-0   1/1     Running   0          58s
    cpfs-sts-1   1/1     Running   0          50s
  4. Check the mount point in the container to verify that CPFS is mounted.

    kubectl exec cpfs-sts-0 -- mount | grep /data

    The following output indicates that the CPFS General-purpose Edition static volume is mounted.

    cpfs-******-******.cn-shanghai.cpfs.aliyuncs.com:/share on /data type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,port=30000,timeo=600,retrans=2,sec=sys,mountaddr=127.0.1.255,mountvers=3,mountport=30000,mountproto=tcp,local_lock=all,addr=127.0.1.255)

Verify shared storage and persistent storage

After the application is deployed, verify that the volume works as expected.

Shared storage

Create a file in one Pod and view it in another Pod to verify that the data is shared.

  1. View the Pod information to obtain the Pod names.

    kubectl get pod -l app=nginx

    Expected output:

    NAME         READY   STATUS    RESTARTS   AGE
    cpfs-sts-0   1/1     Running   0          10s
    cpfs-sts-1   1/1     Running   0          5s
  2. Create a file in one Pod.

    Use the Pod named cpfs-sts-0 as an example:

    kubectl exec cpfs-sts-0 -- touch /data/test.txt
  3. Check whether the file exists in another Pod.

    Use the Pod named cpfs-sts-1 as an example.

    kubectl exec cpfs-sts-1 -- ls /data

    Expected output:

    test.txt

    The file created earlier is displayed, which indicates that data can be shared among multiple Pods.

Persistent storage

Recreate the Deployment and check whether the data in the file system exists in the new Pod to verify persistent storage.

  1. Delete the application Pod to trigger a rebuild.

    kubectl rollout restart sts cpfs-sts
  2. View the Pods and wait for the new Pods to start and enter the Running state.

    kubectl get pod -l app=nginx

    Expected output:

    NAME         READY   STATUS    RESTARTS   AGE
    cpfs-sts-0   1/1     Running   0          1s
    cpfs-sts-1   1/1     Running   0          10s
  3. Check whether the file created earlier exists in the new Pod.

    Use the Pod named cpfs-sts-0 as an example.

    kubectl exec cpfs-sts-0 -- ls /data

    Expected output:

    test.txt

    The file written earlier is displayed, which indicates that data is stored persistently.

Recommendations for production environments

  • Performance tuning: CPFS is suitable for high-throughput, high-IOPS workloads. Adjust the NFS mount parameters in the PV mountOptions field, such as rsize and wsize, to optimize performance and meet specific workload requirements.

  • Data consistency: As shared storage, CPFS does not guarantee data consistency when multiple Pods write to the same file concurrently. To prevent file corruption, implement distributed locks at the application layer or use an append-only write pattern.

  • Volume management: Static volumes require you to manage PVs manually. If you need to automatically create and isolate volumes for multiple applications, use CNFS to manage CPFS dynamic volumes. For more information, see Manage General-purpose CPFS dynamic volumes.