Container Network File System (CNFS) creates Kubernetes CustomResourceDefinitions (CRDs) for Alibaba Cloud file stores and allows you to manage them separately. You can create, delete, describe, mount, monitor, and expand these CRDs. You can use CNFS to create or manage existing File Storage NAS (NAS) file systems. This improves the performance of NAS file systems, implements quality of service (QoS) control, and enables you to manage the file system layer separately. This topic describes how to use CNFS to manage NAS file systems.
Prerequisites
NAS is activated.
If this is the first time you visit the product page of NAS, follow the on-screen instructions to activate the NAS service.
A Container Service for Kubernetes (ACK) cluster that runs Kubernetes 1.20 or later is created. The Container Storage Interface (CSI) plug-in is used as the volume plug-in. For more information, see Create an ACK managed cluster.
The versions of csi-plugin and csi-provisioner are v1.24.11-5221f79-aliyun or later. For more information about how to update csi-plugin and csi-provisioner, see Install and update the CSI components.
The version of storage-operator is v1.24.105-825188d-aliyun or later. For more information about how to update storage-operator, see Manage components.
A kubectl client is connected to your cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.
NoteFor more information about CNFS, see CNFS overview.
For more information about how to use CNFS to manage NAS file systems, see Use CNFS to manage NAS file systems (recommended).
Procedure
You can use CNFS to manage NAS file systems by using one of the following methods:
Method 1: Use CNFS to manage a newly created NAS file system
Run the following command to use CNFS to create and manage a Capacity NAS file system.
NoteCapacity NAS file systems are billed based on the actual usage. You can create Capacity NAS file systems free of charge. For more information, see Billing overview.
You are not charged for enabling the recycle bin feature. However, you are charged for the storage space occupied by files that are temporarily stored in the recycle bin. The storage fees are calculated based on the storage type of the files before the files are deleted. For more information, see Recycle bin.
cat << EOF | kubectl apply -f - apiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerNetworkFileSystem metadata: name: cnfs-nas-filesystem spec: description: "cnfs" type: nas reclaimPolicy: Retain parameters: filesystemType: standard storageType: Capacity # Create a Capacity NAS file system. protocolType: NFS encryptType: None enableTrashCan: "true" # Enable the recycle bin. trashCanReservedDays: "5" # Set the retention period of the data in the recycle bin to five days. EOF
Run the following command to query NAS file systems managed by CNFS:
kubectl get cnfs cnfs-nas-filesystem -oyaml
Expected output:
Method 2: Use CNFS to manage an existing NAS file system
To use CNFS to manage an existing NAS file system, make sure that the NAS file system has a mount target in the virtual private cloud (VPC) of the ACK cluster. For more information about how to query mount targets, see Manage mount targets.
Run the following command to enable CNFS to manage the NAS file system:
cat << EOF | kubectl apply -f - apiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerNetworkFileSystem metadata: name: cnfs-nas-filesystem spec: description: "cnfs" type: nas reclaimPolicy: Retain parameters: server: 971134b0e8-****.cn-zhangjiakou.nas.aliyuncs.com # The mount target of the NAS file system. EOF
Run the following command to query NAS file systems managed by CNFS:
kubectl get cnfs cnfs-nas-filesystem -oyaml
Expected output:
References
For more information about how to mount a directory in a NAS file system to multiple applications or pods for data sharing, see Use CNFS to manage shared NAS volumes (recommended).
For more information about how to mount different directories in a NAS file system to multiple applications or pods for data isolation, see Use CNFS to manage isolated NAS volumes (recommended).
For more information about how to automatically expand a NAS volume when the storage usage exceeds a threshold, see Use CNFS to automatically expand NAS volumes.