All Products
Search
Document Center

File Storage NAS:Mount a NAS file system by using a volume

Last Updated:Feb 28, 2026

Use a Kubernetes in-tree NFS volume to mount a NAS file system on a self-managed Kubernetes cluster.

Prerequisites

Before you begin, make sure that you have:

  • A NAS file system with the NFS protocol enabled. To encrypt data, configure the encryption type when you create the file system. For more information, see Create a file system.

  • A mount target for the NAS file system. For more information, see Manage mount targets.

  • A self-managed Kubernetes cluster that runs Kubernetes 1.16 or later.

  • Ports 111 and 2049 open in the security group of the worker nodes. For more information, see Add a security group rule.

  • A network connection to Alibaba Cloud through Express Connect, Smart Access Gateway (SAG), or VPN Gateway if the cluster is in an on-premises data center.

Limits

The limits on mounting scenarios, the number of file systems, and file sharing protocols vary based on the storage type of NAS file systems. For more information, see Limits.

Important

Do not delete the mount target of a NAS file system before you unmount it. Deleting a mount target while the file system is still mounted may cause the operating system to become unresponsive.

Procedure

Step 1: Install and configure the NFS client

Perform the following steps on every node in the cluster. Complete these steps before you add a new node.

  1. Install the NFS client. For more information, see Step 1: Install the NFS client.

  2. Run the following command to configure the /etc/nfsmount.conf file:

    cat <<EOF >> /etc/nfsmount.conf
    [ Server "file-system-id.region.nas.aliyuncs.com" ]
    vers=3
    Proto=tcp
    Lock=False
    resvport=False
    rsize=1048576
    wsize=1048576
    hard=True
    timeo=600
    retrans=2
    EOF

    Replace file-system-id.region.nas.aliyuncs.com with the DNS name of your mount target. To find the DNS name:

    1. Log on to the NAS console.

    2. On the File System List page, click the file system ID.

    3. Click the Mount Targets tab and hover over the copy icon in the Mount Target column.

    The following table describes the key parameters:

    Parameter

    Description

    vers

    The NFS protocol version. We recommend NFSv3.

    rsize / wsize

    The read and write buffer sizes, in bytes. Default: 1048576 (1 MiB).

    hard

    Enables hard mounts. The client retries NFS requests indefinitely until the server responds.

    timeo

    The timeout for NFS requests, in tenths of a second. Default: 600 (60 seconds).

    retrans

    The number of retries before the client reports an error. Default: 2.

    Note

    All parameters are required. Only modify the mount target DNS name and the vers value. Keep all other parameters unchanged.

Step 2: Verify the network connection

  1. Run the following command to mount the NAS file system to a temporary directory:

    mount -t nfs file-system-id.region.nas.aliyuncs.com:/ /mnt

    Replace file-system-id.region.nas.aliyuncs.com with the DNS name of your mount target.

    Note

    If the mount fails, ping the mount target DNS name and verify that port 2049 is reachable. If the failure is not caused by network issues, use the troubleshooting script. For more information, see Automatic check script for failures to mount an NFS file system on a Linux server.

  2. Run the following command to verify the mount parameters:

    mount | grep nfs | grep mnt

    If the output contains vers=3, hard, noresvport, and nolock, the connection is successful.

  3. After you confirm the connection, run the following command to unmount the temporary mount:

    umount /mnt

Step 3: Deploy a pod with a NAS volume

The following example creates an nginx Deployment that mounts a NAS file system.

  1. Create a file named nginx.yaml with the following content:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 1
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.14.2
            ports:
            - containerPort: 80
            volumeMounts:
            - mountPath: /data
              name: test-nfs
          volumes:
          - name: test-nfs
            nfs:
              server: file-system-id.region.nas.aliyuncs.com    # Replace with the DNS name of your mount target. Example: 7bexxxxxx-xxxx.ap-southeast-1.nas.aliyuncs.com.
              path: /    # Use "/" for General-purpose NAS or "/share" for Extreme NAS.
  2. Run the following command to deploy the pod:

    kubectl apply -f ./nginx.yaml

Step 4: Verify the mount

  1. Run the following command to check the pod status:

    kubectl get pods | grep nginx

    Expected output:

    If the pod is in the Running state, the pod started successfully.

  2. Run the following command to verify that the NAS file system is mounted:

    kubectl exec nginx-deployment-9b9b684f5-xxxxx -- df -h /data

    Replace nginx-deployment-9b9b684f5-xxxxx with the actual pod name from the previous step.

    If the output shows the NAS file system mounted at /data, the mount is successful.