All Products
Search
Document Center

Container Service for Kubernetes:Mount a statically provisioned NAS volume

Last Updated:Sep 29, 2026

This topic explains how to mount an Alibaba Cloud Network Attached Storage (NAS) volume to pods in a Container Service for Kubernetes (ACK) cluster using static provisioning. Static provisioning lets you connect pods to an existing NAS file system for persistent, shared storage across multiple pods simultaneously.

Prerequisites

Use cases

  • Applications with high disk I/O requirements.

  • Supports cross-host file sharing, for example, as a file server.

Notes

  • When using an Extreme NAS file system, the path configured for the PersistentVolume (PV) must use /share as the parent directory. For example, the NAS file system subdirectory mounted by a Pod can be set to /share/path1.

  • NAS supports simultaneous mounting by multiple Pods. In this case, multiple Pods may modify the same data concurrently, and the application must implement data synchronization on its own.

    Note

    The / directory in NAS storage does not support modifying permissions, ownership, or group.

  • If you configure the securityContext.fsgroup parameter in an application template, Kubelet will perform chmod or chown operations after the PersistentVolume (PV) is mounted, which increases the mount time.

    Note

    If the securityContext.fsgroup parameter has been configured and you need to reduce the mount time, see NAS volume FAQ.

Mount a NAS volume using the console

Step 1: Create a PV

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Cluster List page, click the name of the destination cluster or click Details in the Actions column.

  3. In the left navigation pane of the cluster management page, choose Storage > Persistent Volume.

  4. On the Persistent Volumes page, click Create in the upper-right corner.

  5. In the Create PV dialog box, configure the parameters.

    Parameter

    Note

    PV Type

    In this example, NAS is selected.

    Name

    The name of the PersistentVolume (PV) to be created. The PV name must be unique within the cluster. In this example, the name is pv-nas.

    Capacity

    The capacity of the PersistentVolume (PV) to be created. Note that the NAS file system itself does not impose usage limits. This is not a quota on the NAS file system, but a capacity declaration for the PV being created.

    Access Mode

    Select ReadWriteMany and ReadWriteOnce. The default value is ReadWriteMany.

    Mount Target Domain Name:

    You can define the mount address of the cluster at the NAS mount point using either Select Mount Target or Custom.

    Advanced Options (Optional)

    Mount Path

    The NAS subdirectory to mount. If this parameter is not specified, the root directory is mounted by default.

    If the directory does not exist in the NAS file system, it is automatically created and then mounted.
    • General-purpose NAS: The root directory is /.

    • Extreme NAS: The root directory is /share. When you mount a subdirectory, the path must start with /share, such as /share/data.

    Reclaim Policy

    Retain (default): When the PVC is deleted, the PV and NAS files are not deleted. You must manually delete them.

    Mount Options

    The mount options for NAS, including the NFS protocol version. By default, volumes are mounted using NFSv3. You can specify a different version with an option such as vers=4.0. For information about the NFS protocols supported by different NAS types, see NFS protocols.

    Labels

    Add labels to this PersistentVolume (PV).

  6. After configuring the parameters, click Create.

Step 2: Create a PVC

  1. In the left navigation pane of the cluster management page, choose Storage > PVCs.

  2. On the Persistent Volume Claims page, click Create in the upper-right corner.

  3. In the Create PVC dialog box that appears, fill in the parameters.

    Parameter

    Note

    PVC Type

    In this example, NAS is selected.

    Name

    The name of the PersistentVolumeClaim (PVC) to be created must be unique within the cluster.

    Allocation Mode

    Select an existing PersistentVolume (PV).

    Note

    If no PV has been created, you can set Allocation Mode to Create PV to configure the parameters for creating a PV. For more information, see Create a PV.

    Existing Volumes

    Click Select PV, then in the Actions column to the right of the target PV, click Select Node to select the PV.

    Capacity

    The capacity of the PersistentVolume (PV) to be created.

    Note

    The capacity of the PersistentVolumeClaim (PVC) to be created cannot exceed the capacity of the PersistentVolume (PV) to be mounted.

  4. Click Create.

    After the PersistentVolumeClaim (PVC) is created, you can see it in the list, and it is already bound to the corresponding PersistentVolume (PV).

Step 3: Create an application

  1. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

  2. On the Deployments page, click Create from Image and configure the application parameters.

    The following table describes the main parameters. You can keep the default values for other parameters. For more information, see Create a stateless Deployment.

    Category

    Parameter

    Description

    Basic Information

    Application Name

    The name of the Deployment.

    Replicas:

    The number of replicas for the Deployment.

    This setup lets you verify the shared storage feature of NAS.

    Container

    Image Name

    The address of the application image.

    Required Resources

    The required vCPU and memory resources.

    Volume

    Click Add PVC and configure the parameters.

    • Mount Source: Select the PVC that you created earlier.

    • Container Path: The path within the container to mount the NAS file system, such as /data.

    When the deployment finishes, go to the Deployments page and click the application's name. On the Pods tab, verify that the Pods are in the Running state.

Mount a NAS volume using kubectl

  1. Run the following command to create a static PV.

    kubectl create -f pv-nas.yaml

    The following is a sample YAML file for creating a static PV.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: pv-nas
      labels:
        alicloud-pvname: pv-nas
    spec:
      capacity:
        storage: 5Gi
      accessModes:
        - ReadWriteMany
      csi:
        driver: nasplugin.csi.alibabacloud.com
        volumeHandle: pv-nas
        volumeAttributes:
          server: "2564f4****-ysu87.cn-shenzhen.nas.aliyuncs.com"
          path: "/csi"
      mountOptions:
      - nolock,tcp,noresvport
      - vers=3

    Parameter

    Note

    name

    The name of the PV.

    labels

    Set labels for the PV.

    storage

    The available capacity of NAS.

    accessModes

    Configure the access mode.

    driver

    The driver type. In this example, the value is nasplugin.csi.alibabacloud.com, indicating that the Alibaba Cloud NAS CSI plugin is used.

    volumeHandle

    Configure a unique identifier for the PV. If multiple PVs are used simultaneously, this value must be different for each PV.

    server

    NAS mount point.

    path

    Mount subdirectory. For Extreme NAS, /share must be used as the parent directory.

    vers

    The NFS protocol version for mounting the NAS PersistentVolume (PV). v3 is recommended. Extreme NAS only supports v3.

  2. Run the following command to create a static PVC.

    Create a NAS PersistentVolumeClaim (PVC) and use selector to filter PVs, precisely configuring the binding between the PVC and PV.

    kubectl create -f pvc-nas.yaml

    The following is a sample YAML file for creating a static PVC.

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: pvc-nas
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 5Gi
      selector:
        matchLabels:
          alicloud-pvname: pv-nas

    Parameter

    Note

    name

    The name of the PVC.

    accessModes

    Configure the access mode.

    storage

    Declare the application usage, which cannot exceed the total capacity of the PersistentVolume (PV).

    matchLabels

    Enter the PV label to associate with the PV.

  3. Run the following command to create an application named nas-static and mount the PVC.

    kubectl create -f nas.yaml

    The following is a sample nas.yaml file for creating the nas-static application.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nas-static
      labels:
        app: nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
            ports:
            - containerPort: 80
            volumeMounts:
              - name: pvc-nas
                mountPath: "/data"
          volumes:
            - name: pvc-nas
              persistentVolumeClaim:
                claimName: pvc-nas

    Parameter

    Note

    mountPath

    The mount path of NAS in the container.

    claimName

    The name of the PVC, used to bind the PVC.

  4. Run the following command to view Pod information.

    kubectl get pod

    Expected output:

    NAME                          READY   STATUS    RESTARTS   AGE
    nas-static-5b5cdb85f6-n****   1/1     Running   0          32s
    nas-static-c5bb4746c-4****    1/1     Running   0          32s

Verify persistent storage of NAS

  1. View the deployed application and NAS files.

    1. Run the following command to view the name of the deployed application.

      kubectl get pod 

      Expected output:

      NAME                          READY   STATUS    RESTARTS   AGE
      nas-static-5b5cdb85f6-n****   1/1     Running   0          32s
      nas-static-c5bb4746c-4****    1/1     Running   0          32s
    2. Run the following command to view the files under the /data path of any application. In this example, the Pod named nas-static-5b5cdb85f6-n**** is used.

      kubectl exec nas-static-5b5cdb85f6-n**** -- ls /data

      No output is returned, indicating that there are no files under the /data path.

  2. Run the following command to create a file nas under the /data path of the Pod named nas-static-5b5cdb85f6-n****.

    kubectl exec nas-static-5b5cdb85f6-n**** -- touch /data/nas
  3. Run the following command to view the files under the /data path of the Pod named nas-static-5b5cdb85f6-n****.

    kubectl exec nas-static-5b5cdb85f6-n**** -- ls /data

    Expected output:

    nas
  4. Run the following command to delete the Pod.

    kubectl delete pod nas-static-5b5cdb85f6-n****
  5. At the same time, in another window, run the following command to view the process of Pod deletion and Kubernetes rebuilding the Pod.

    kubectl get pod -w -l app=nginx
  6. Verify whether the files created in NAS still exist after the Pod is deleted.

    1. Run the following command to view the name of the Pod rebuilt by Kubernetes.

      kubectl get pod

      Expected output:

      NAME                                READY   STATUS    RESTARTS   AGE
      nas-static-5b5cdb85f6-n****   1/1     Running   0          32s
      nas-static-c5bb4746c-4****    1/1     Running   0          32s
    2. Run the following command to view the files under the /data path of the Pod named nas-static-5b5cdb85f6-n****.

      kubectl exec nas-static-5b5cdb85f6-n**** -- ls /data

      Expected output:

      nas

      The nas file still exists, indicating that NAS data can be stored persistently.

Verify shared storage

  1. View the Pods where the deployed application runs and the NAS files.

    1. Run the following command to view the names of the Pods where the application runs.

      kubectl get pod 

      Expected output:

      NAME                          READY   STATUS    RESTARTS   AGE
      nas-static-5b5cdb85f6-n****   1/1     Running   0          32s
      nas-static-c5bb4746c-4****    1/1     Running   0          32s
    2. Run the following command to view the files under the /data path of the 2 Pods.

      kubectl exec nas-static-5b5cdb85f6-n**** -- ls /data
      kubectl exec nas-static-c5bb4746c-4**** -- ls /data
  2. Run the following command to create a file nas under the /data path of any Pod.

     kubectl exec nas-static-5b5cdb85f6-n**** -- touch /data/nas
  3. Run the following command to view the files under the /data path of the 2 Pods.

    1. Run the following command to view the files under the /data path of the Pod named nas-static-5b5cdb85f6-n****.

      kubectl exec nas-static-5b5cdb85f6-n**** -- ls /data

      Expected output:

      nas
    2. Run the following command to view the files under the /data path of the Pod named nas-static-c5bb4746c-4****.

      kubectl exec nas-static-c5bb4746c-4**** -- ls /data

      Expected output:

      nas

      If the file created under the /data path of any Pod is present under the /data path of both Pods, it indicates that the two Pods share the same NAS.