All Products
Search
Document Center

File Storage NAS:Mount NAS through a Kubernetes volume

Last Updated:Jun 03, 2026

Mount NAS on a self-managed Kubernetes cluster using an in-tree NFS volume.

Prerequisites

Before you begin, make sure the following requirements are met:

  • An NFS-protocol NAS file system is created. To encrypt data, enable encryption during file system creation. For more information, see Create a file system.

  • A mount target is added to the file system. For more information, see Manage mount targets.

  • A self-managed Kubernetes cluster running version 1.16 or later.

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

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

Limits

Limits on mounting scenarios, file system count, and file sharing protocols vary by NAS storage type. For more information, see Limits.

Important

Do not delete a mount target before unmounting the file system. The operating system may become unresponsive.

Procedure

Step 1: Install and configure the NFS client

Repeat these steps on every cluster node, including nodes added later.

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

  2. Configure /etc/nfsmount.conf:

    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.

    Key parameters:

    Parameter

    Description

    vers

    NFS protocol version. Recommended: NFSv3.

    rsize / wsize

    Read and write buffer sizes in bytes. Default: 1048576 (1 MiB).

    hard

    Hard mount mode. The client retries indefinitely until the server responds.

    timeo

    NFS request timeout in tenths of a second. Default: 600 (60 seconds).

    retrans

    Retries before the client reports an error. Default: 2.

    Note

    All parameters are required. Only change the mount target DNS name and the vers value.

Step 2: Verify the network connection

  1. 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 check that port 2049 is reachable. For non-network failures, run the troubleshooting script. For more information, see Automatic check script for NFS mount failures.

  2. Verify the mount parameters:

    mount | grep nfs | grep mnt

    Output containing vers=3, hard, noresvport, and nolock confirms a successful connection.

  3. Unmount the temporary mount:

    umount /mnt

Step 3: Deploy a pod with a NAS volume

The following example creates an nginx Deployment with a NAS volume mount.

  1. Create nginx.yaml:

    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. Deploy the pod:

    kubectl apply -f ./nginx.yaml

Step 4: Verify the mount

  1. Check the pod status:

    kubectl get pods | grep nginx

    Expected output:

    A Running state confirms the pod started successfully.

  2. Verify 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.

    Output showing the file system mounted at /data confirms success.