All Products
Search
Document Center

Container Service for Kubernetes:Use a static NAS volume

Last Updated:Aug 24, 2026

You can use the FlexVolume plugin to access Alibaba Cloud File Storage NAS. This topic describes how to use a statically provisioned File Storage NAS volume.

Prerequisites

Background information

The FlexVolume plugin allows you to use Alibaba Cloud File Storage NAS as persistent volumes (PVs) by creating PVs and persistent volume claims (PVCs).

Precautions

If you configure the securityContext.fsgroup parameter in an application template, the kubelet runs a chmod or chown operation after the volume is mounted. This can significantly increase the mount time.

Note

To reduce mount times when the securityContext.fsgroup parameter is configured, see Extended mount times for File Storage NAS volumes.

Procedure

A pod uses a statically provisioned File Storage NAS volume by referencing a PV and a PVC.

  1. Create a PV.

    You can create a PV by using a YAML file or in the ACK console.

    • Create a PV by using a YAML file.

      Use the following nas-pv.yaml file to create a PV:

      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: pv-nas
      spec:
        capacity:
          storage: 5Gi
        storageClassName: nas
        accessModes:
          - ReadWriteMany
        flexVolume:
          driver: "alicloud/nas"
          options:
            server: "0cd8b4a576-u****.cn-hangzhou.nas.aliyuncs.com"
            path: "/k8s"
            vers: "3"
            options: "nolock,tcp,noresvport"
    • Create a File Storage NAS persistent volume in the ACK console.

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

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

      3. On the cluster management page, in the navigation pane on the left, choose Volumes > Persistent Volumes.

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

      5. In the Create Persistent Volume dialog box, configure the parameters.

        Parameter

        Description

        PV Type

        In this example, select File Storage NAS.

        Volume Name:

        A unique name for the persistent volume within the cluster. This example uses pv-nas.

        Volume Plug-in

        In this example, select FlexVolume.

        Capacity

        The capacity of the persistent volume. This value cannot exceed the total capacity of the File Storage NAS file system.

        Access Mode

        The default value is ReadWriteMany.

        Mount Target Domain Name:

        The mount target domain name of the File Storage NAS file system. For more information, see Manage mount targets.

        Subdirectory

        A subdirectory of the File Storage NAS path to which the persistent volume is mounted. The path must start with a forward slash (/).

        • If the subdirectory does not exist in the root directory, it is automatically created and then mounted.

        • You can leave this parameter empty to mount the root directory.

        • For Extreme NAS, the path must start with /share.

        Permissions:

        The access permissions for the mounted directory, such as 755, 644, or 777.

        Note
        • Permissions can be set only for a subdirectory, not the root directory.

        • To avoid long execution times for the chmod command, do not set this parameter if the mounted directory contains many files.

        When you mount a File Storage NAS subdirectory, this parameter is optional.

        • If you do not set this parameter, the original permissions of the files in the File Storage NAS file system are used.

        • If you set this parameter:

          • For FlexVolume versions earlier than v1.14.6.15-8d3b7e7-aliyun, permissions are applied recursively to all files and directories under the mount path.

          • For FlexVolume v1.14.6.15-8d3b7e7-aliyun and later, permissions are applied based on the chmod (Change Mode) setting.

        chmod (Change Mode)

        Specifies how permissions are changed. You can choose non-recursive or recursive.

        • Non-recursive: Permission changes apply only to the mounted directory, not to the subdirectories or files it contains.

        • Recursive: Permission changes are applied recursively to all subdirectories and files within the mounted directory.

          Note

          If the mounted directory contains many files, using the recursive mode can cause the chmod command to run for a long time. This may lead to mount or unmount failures. Use this option with caution.

        Version

        The NFS protocol version for the mounted File Storage NAS volume. V3 is recommended. Extreme NAS only supports V3.

        Label

        A label to add to the persistent volume.

      6. After you configure the parameters, click Create.

  2. Create a PVC.

    Use the following nas-pvc.yaml file to create a PVC:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-nas
    spec:
      accessModes:
        - ReadWriteMany
      storageClassName: nas
      resources:
        requests:
          storage: 5Gi
  3. Create a pod.

    Use the following nas-pod.yaml file to create a pod:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nas-static
      labels:
        app: nginx
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            ports:
            - containerPort: 80
            volumeMounts:
              - name: pvc-nas
                mountPath: /data
          volumes:
            - name: pvc-nas
              persistentVolumeClaim:
                claimName: pvc-nas