All Products
Document Center

Use FlexVolume to mount a NAS volume

Last Updated: May 19, 2022

This topic describes how to use FlexVolume to mount a volume of the Apsara File Storage Network Attached Storage (NAS) type to an elastic container instance.


  • Your Kubernetes cluster is deployed with Virtual Kubelet.

    Alibaba Cloud Serverless Kubernetes (ASK) clusters are integrated with Virtual Kubelet. For other types of clusters, you must manually deploy Virtual Kubelet. For more information, see Connect an elastic container instance to a Kubernetes cluster.

  • A NAS file system and mount point are created.

    The NAS file system, mount point, and Virtual Kubelet must be in the same virtual private cloud (VPC). The default mount directory is /. If you want to specify a different mount directory, create a subdirectory in NAS. For more information, see Get started with Apsara File Storage NAS.

Configuration example

  1. Prepare a YAML configuration file.

    vim flexvolume_nas.yaml

    The following code provides an example flexvolume_nas.yaml file.

    apiVersion: v1
    kind: Pod
      name: test-flexvolume-nas
      labels: "true"
      - image: nginx:latest
        name: test-container
        - mountPath: /cache-test
          name: cache-volume
      - name: cache-volume
          driver: alicloud/nas
          fsType: nfs
            server: "133aa4****"
            path: "/"
            vers: "3"
            options: "nolock,tcp,noresvport"
  2. Deploy a pod.

    kubectl create -f flexvolume_nas.yaml
  3. View the mount result.

    Run the ls command to view the file directory in the pod. The mount directory /cache-test of the NAS volume is generated in the pod.

    Mount a NAS volume to an elastic container instance