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.
Prerequisites
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
Prepare a YAML configuration file.
vim flexvolume_nas.yaml
The following code provides an example flexvolume_nas.yaml file.
apiVersion: v1 kind: Pod metadata: name: test-flexvolume-nas labels: alibabacloud.com/eci: "true" spec: containers: - image: nginx:latest name: test-container volumeMounts: - mountPath: /cache-test name: cache-volume volumes: - name: cache-volume flexVolume: driver: alicloud/nas fsType: nfs options: server: "133aa4****-rvn26.cn-beijing.nas.aliyuncs.com" path: "/" vers: "3" options: "nolock,tcp,noresvport"
Deploy a pod.
kubectl create -f flexvolume_nas.yaml
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.