All Products
Search
Document Center

Container Service for Kubernetes:Mount NAS via EFC client with CNFS

Last Updated:Jul 28, 2025

The Elastic File Client (EFC) enhances performance for File Storage NAS (Network Attached Storage) by leveraging distributed caching to accelerate access. It supports high-concurrency and large-scale parallel data access, making it ideal for data-intensive containerized applications such as big data analytics, AI training, and inference workloads. Compared to the traditional Network File System (NFS) protocol, EFC delivers significantly improved I/O performance and lower latency. This topic explains how to mount NAS file systems using the EFC client through Container Network File System (CNFS).

EFC overview

EFC is Alibaba Cloud's user-space POSIX-compliant client built on Filesystem in Userspace (FUSE). It replaces traditional kernel-mode NFS clients and provides enhanced performance, reliability, and operational efficiency. Key capabilities include:

  • Multi-connection access

  • Metadata and data caching

  • Distributed read-only caching

  • Integrated monitoring via Managed Service for Prometheus

Compared to kernel-mode NFS clients and other open-source FUSE clients, the EFC client offers the following advantages:

  • Strong data consistency

    Implemented for files and directories through a strongly consistent distributed locking mechanism. Ensures:

    • Immediate visibility of written files to other clients

    • Instant synchronization of newly created files across all clients

    • Simplified multi-node data management

  • Single-node read and write caching

    Optimizes the FUSE caching logic by using a small amount of compute node memory to cache data, delivering:

    • Enhanced throughput for small files

    • Over 50% I/O performance versus traditional NFS clients

  • Distributed read-only caching

    Constructs an auto-scaling, O&M-free distributed cache pool using memory across multiple nodes.

  • Small file prefetching

    Automatically identifies and prefetches hot directories and files to reduce the overhead of pulling data.

  • Hot upgrade and failover

    • Client updates without application restarts

    • Automatic failover during client failures, with no service interruption

Prerequisites

Before using EFC, ensure the following:

  • The cnfs-nas-daemon add-on is installed in your cluster. The AlinasMountProxy=true flag is added in the FeatureGate of csi-plugin. For details, see Manage cnfs-nas-daemon.

  • The node OS is Alibaba Cloud Linux 3 or ContainerOS, with kernel version 5.10.134-17.2 or later.

    Important

    Nodes that do not meet these requirements will automatically fall back to the NFS protocol for mounting.

(Optional) Deploy CNFS-EFC distributed cache

To enable EFC's distributed cache capability, deploy the CNFS-EFC distributed cache plugin.

  1. Create a ConfigMap for csi-plugin to deploy the CNFS-EFC distributed cache plugin.

    After the ConfigMap is deployed, the system automatically provisions the cached DaemonSet and associated Services based on the ConfigMap.

    1. Save the following YAML template as csi-configmap.yaml.

      The DaemonSet creates pods on nodes with the cache=true label. Each pod contains three containers and mounts a 15 GiB tmpfs volume (memory-based). Modify the parameter configurations as needed.

      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: csi-plugin
        namespace: kube-system
      data:
        nas-efc-cache: |
          enable=true
          container-number=3
          volume-type=memory
          volume-size=15Gi
        node-selector: |
          cache=true

      Parameter

      Description

      nfs-efc-cache

      enable

      Set this parameter to true to enable distributed caching.

      container-number

      The number of containers per cached DaemonSet pod. Increase this parameter when cache performance bottlenecks occur.

      volume-type

      The storage medium used by the EmptyDir volume mounted to cache pods.

      • disk

      • memory

      Important

      Ensure resource usage on nodes does not impact production workloads.

      volume-size

      Size of the volume allocated per cache pod (unit: GiB).

      node-selector

      Labels used to schedule the cache DaemonSet. If not set, the DaemonSet runs on all nodes.

    2. Run the following command to deploy the ConfigMap:

      kubectl apply -f csi-configmap.yaml
  2. Verify the distributed-cached DaemonSet status:

    kubectl get ds/cnfs-cache-ds -n kube-system -o wide

    Expected output:

    NAME            DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE   CONTAINERS                                                            IMAGES                                                                                                                                                                                   SELECTOR
    cnfs-cache-ds   2         2         2       2            2           cache=true      13m   alinas-dadi-container,alinas-dadi-container1,alinas-dadi-container2   registry-cn-hangzhou.ack.aliyuncs.com/acs/nas-cache:20220420,registry-cn-hangzhou.ack.aliyuncs.com/acs/nas-cache:20220420,registry-cn-hangzhou.ack.aliyuncs.com/acs/nas-cache:20220420   app=cnfs-cache-ds

    In this sample output, the cluster has two nodes with the cache=true label, and the two pods in the DaemonSet are both in the ready state, indicating the distributed cache DaemonSet has been started.

  3. Verify service discovery for the distributed cache Service:

    kubectl get ep cnfs-cache-ds-service  -n kube-system -o wide

    Expected output:

    NAME                    ENDPOINTS                                                              AGE
    cnfs-cache-ds-service   192.168.3.217:6500,192.168.5.247:6500,192.168.3.217:6502 + 3 more...   2d3h

    The sample output indicates the Service has discovered backend cache pod endpoints.

Configure CNFS to mount NAS using the EFC client

  1. Create a CNFS and specify the use of the EFC client.

    1. Save the following YAML template as cnfs-efc.yaml.

      This example demonstrates enabling the EFC client when configuring an existing NAS file system via CNFS. For new NAS file systems created through CNFS, add useClient: EFCClient in the parameters section of the ContainerNetworkFileSystem resource to enable the EFC client. For details, see Use CNFS to manage NAS file systems (recommended).

      apiVersion: storage.alibabacloud.com/v1beta1
      kind: ContainerNetworkFileSystem
      metadata:
        name: cnfs-efc-test
      spec:
        description: "cnfs"
        type: nas
        reclaimPolicy: Retain
        parameters:
          server: 17f7e4****-h****.cn-beijing.nas.aliyuncs.com
          useClient: EFCClient

      Parameter

      Description

      description

      The description of the file system.

      type

      The type of the volume to be created.

      reclaimPolicy

      The reclaim policy. Only the Retain policy is supported. Deleting CNFS does not delete the NAS file system.

      parameters

      server

      The mount target address. The mount target must meet the following requirements:

      • The VPC of the mount target must be the same as the VPC used by the pods. Otherwise, the mounting will fail.

      • We recommend using the same vSwitch for the mount target and the pods for optimal performance.

      • The mount target status must be Ready.

      If existing mount targets do not meet these requirements, create a new one.

      useClient

      Set this parameter to EFCClient to enable the EFC client.

    2. Run the following command to create a CNFS:

      kubectl create -f cnfs-efc.yaml
  2. Use CNFS to create a volume:

    kubectl create -f cnfs-pv-pvc.yaml

    Save the following YAML template as cnfs-pv-pvc.yaml.

    If the CNFS-EFC distributed cache is deployed in the cluster, configure EFC to enable caching and prefetching capabilities through mountOptions. If not deployed, remove the mountOptions configuration from the example.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: efc-pv
    spec:
      accessModes:
      - ReadWriteMany
      capacity:
        storage: 50Gi
      claimRef:
        name: efc-pvc
        namespace: default
      csi:
        driver: nasplugin.csi.alibabacloud.com
        volumeAttributes:
          containerNetworkFileSystem: cnfs-efc-test
          path: /
        volumeHandle: efc-pv
      mountOptions:
      - g_tier_EnableClusterCache=true              # The distributed caching configuration when mounting the volume.
      - g_tier_EnableClusterCachePrefetch=true      # Enable prefetching when mounting the volume.
      volumeMode: Filesystem
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: efc-pvc
      namespace: default
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 50Gi
      storageClassName: ""
      volumeMode: Filesystem
      volumeName: efc-pv

Create a workload and mount NAS

  1. Create a Deployment and mount the NAS file system to it:

    kubectl create -f cnfs-deployment.yaml

    Save the following YAML template as cnfs-deployment.yaml:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: efc-test
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: efc-test
      template:
        metadata:
          labels:
            app: efc-test
        spec:
          containers:
          - command:
            - sh
            - -c
            - |
              sleep infinity
            image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
            name: test
            volumeMounts:
            - mountPath: /mnt
              name: pvc
          volumes:
          - name: pvc
            persistentVolumeClaim:
              claimName: efc-pvc
  2. Check the status of pods in the Deployment:

    kubectl get pod -l app=efc-test

    Expected output:

    NAME                       READY   STATUS    RESTARTS   AGE
    efc-test-f545b86d6-spr7p   1/1     Running   0          29m
  3. After the pod reaches the Running state, verify the EFC mount point in the pod:

    kubectl exec <pod-name> -- mount -t fuse.aliyun-alinas-efc

    Expected output:

    bindroot-3889a-8TzEY5mc:3d2804****-w****.cn-shanghai.nas.aliyuncs.com:/ on /mnt type fuse.aliyun-alinas-efc (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=1048576)