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 manage File Storage NAS (NAS) file systems separately in order to improve the performance and quality of service (QoS) control of NAS file systems. This topic describes how to use CNFS to manage NAS file systems and how to use CNFS to mount volumes to workloads.
Prerequisites
NAS is activated.
The first time you visit the product page of NAS, follow the on-screen instructions to activate the NAS service.
An ACK Pro cluster is created and the Kubernetes version of the cluster is later than 1.20. If you use CNFS through kubectl, clusters that run Kubernetes 1.20 are supported. For more information, see Create an ACK managed cluster.
The csi-plugin, csi-provisioner and storage-operator components are updated to the latest version. For more information about how to update components, see Manage components. When you use CNFS, the component versions must meet the following requirements:
The versions of csi-plugin and csi-provisioner are 1.20.5-ff6490f-aliyun or later.
The version of storage-operator is 1.18.8.56-2aa33ba-aliyun or later. If you use CNFS in the console, the version of storage-operator must be 1.26.2-1de13b6-aliyun or later.
Before you can use CNFS through kubectl, you must use kubectl to connect to the cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.
Capacity NAS file systems and Performance NAS file systems are supported. Advanced NAS file systems and Extreme NAS file systems are not supported. Before you can use Key Management Service (KMS) to encrypt NAS file systems, you must activate KMS. For more information, see Purchase a dedicated KMS instance.
Overview
You can use CNFS to manage NAS file systems by using one of the following methods:
Method 1: Use CNFS to create a default NAS file system
Create a default CNFS file system and use a dynamically provisioned NAS volume to mount the automatically created NAS file system. Then, mount the dynamically provisioned NAS volume to a Deployment and a StatefulSet at the same time.
Method 2: Use CNFS to create a custom NAS file system
Use CNFS to create a custom NAS file system and use a statically or dynamically provisioned NAS volume to mount the created custom NAS file system. Then, mount the statically or dynamically provisioned NAS volume to a Deployment.
Method 3: Create a CNFS file system by using an existing NAS file system
Use CNFS to configure an existing NAS file system and use a statically or dynamically provisioned NAS volume to mount the existing NAS file system. Then, mount the statically or dynamically provisioned NAS volume to a Deployment.
Method 1: Use CNFS to create a default NAS file system
Create a Capacity NAS file system or Performance NAS file system in the virtual private cloud (VPC) where the cluster is deployed. Extreme NAS file systems are not supported. If the region of the cluster does not support NAS file systems of the NAS Capacity type, a NAS file system of the NAS Performance type is created. By default, the created NAS file system is not encrypted.
Use kubectl
Use the following template to create a default CNFS file system and create a dynamically provisioned NAS volume to mount the default NAS file system. Then, mount the dynamically provisioned NAS volume to a Deployment and a StatefulSet.
Parameter | Description |
description | The description of the file system. |
type | The type of the volume that you want to create. |
reclaimPolicy | The reclaim policy of the NAS file system. Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained. |
parameters.encryptType | Optional. The encryption method.
|
parameters.enableTrashCan | Specifies whether to enable the recycle bin feature.
|
Use the console
Create a CNFS file system.
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose
.On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the parameters and click OK.
Parameter
Description
Example
Name
The name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
The type of the file system that you want to host. NAS and OSS are supported.
NAS
Required
You can create a default NAS file system or select an existing NAS file system. If you select an existing NAS file system, you can select an existing NAS mount target or create a custom NAS file system.
Required is displayed only when Select File System Type is set to NAS.
Create Default NAS File System
Description
The description of the CNFS file system.
Use CNFS to create a default NAS file system
End-to-end Data Acceleration
Specifies whether to use the elastic acceleration feature to mount the file system. By default, this feature is disabled. For more information about the elastic acceleration feature, see Enable the distributed caching feature of the CNFS client.
Disabled
On the Container Network File System (CNFS) page, click the name of the CNFS file system to view the CNFS file system details. Click the link next to the NAS ID to go to the File System List page.
On the File System List page, click the Mount Targets tab. In the Mount Target list, move the pointer over the icon in the Mount Target column to view the mount target.
Create a dynamic StorageClass.
On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose .
In the upper-right corner of the StorageClasses page, click Create.
In the Create panel, configure the parameters and click Create.
Parameter
Description
Example
Name
The name of the StorageClass.
The name must start with a lowercase letter, and can contain only lowercase letters, digits, periods (.), and hyphens (-).
alibabacloud-cnfs-nas
PV Type
Valid values: Cloud Disk and NAS.
NAS
Select Mount Target
Set the value to the mount target of the default NAS file system created in Step 1. For more information about how to view the mount target, see View mount targets.
64888******-e*****.cn-qingdao.nas.aliyuncs.com
Reclaim Policy
The reclaim policy of the NAS file system. Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained.
Retain
Mount Options
The mount options, such as the Network File System (NFS) version.
We recommend that you use NFS v3. Extreme NAS file systems support only NFS v3. For more information about the NFS protocol, see NFS.
nolock,tcp,noresvport
vers=3
Mount Path
The mount path of the NAS file system.
/
Create a persistent volume claim (PVC).
In the left-side navigation pane of the details page, choose .
In the upper-right corner of the Persistent Volume Claims page, click Create.
In the Create PVC panel, configure the parameters and click Create.
Parameter
Description
Example
PVC Type
Valid values: Cloud Disk, NAS, and OSS. In this example, NAS is selected.
NAS
Name
The name of the PVC. The name must be unique within the cluster.
cnfs-nas-pvc
Allocation Mode
The allocation mode of the volume.
Use StorageClass
Existing Storage Class
Click Select. Find the PV that you want to use and click Select in the Actions column.
alibabacloud-cnfs-nas
Capacity
The capacity claimed by the PVC.
NoteThe capacity claimed by the PVC cannot exceed the capacity of the PV that is bound to the PVC.
70 Gi
Access Mode
The access mode of the PVC. Default value: ReadWriteMany. You can also select ReadWriteOnce or ReadOnlyMany.
ReadWriteMany
Mount the PVC to the application.
Mount the NAS file system created by using CNFS to the /data path in the container.
Method 2: Use CNFS to create a custom NAS file system
Use kubectl
Use CNFS to create a custom NAS file system and use a statically or dynamically provisioned NAS volume to mount the created custom NAS file system. Then, mount the statically or dynamically provisioned NAS volume to a Deployment.
Create a custom NAS file system.
Run the following command to create a custom 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: filesystemType: standard storageType: Capacity protocolType: NFS encryptType: SSE-KMS enableTrashCan: "true" trashCanReservedDays: "5" vSwitchId: vsw-2ze9l3ppwzg6bl02j**** EOF
Parameter
Description
description
The description of the file system.
type
The type of the volume that you want to create.
reclaimPolicy
The reclaim policy of the NAS file system. Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained.
parameters.filesystemType
The type of the file system. Default value: standard. The default value indicates the General-purpose NAS type.
parameters.storageType
The storage type. If you set filesystemType to standard, the valid values are Performance and Capacity.
parameters.protocolType
The NFS protocol is used. Only NFSv3 is supported.
parameters.encryptType
Optional. The encryption method.
None: The NAS file system is not encrypted.
SSE-KMS: Data is encrypted by using KMS on the NAS server.
parameters.enableTrashCan
Specifies whether to enable the recycle bin feature.
true: enables the recycle bin feature.
false: disables the recycle bin feature.
parameters.trashCanReservedDays
The maximum number of days that the files in the recycle bin are retained. Default value: 7. In this example,
trashCanReservedDays: 5
is used, which indicates that the files in the recycle bin are retained for up to five days.parameters.vSwitchId
The ID of the vSwitch that is used by the created NAS file system.
Run the following command to query the created NAS file system:
kubectl get cnfs
Expected output:
NAME AGE cnfs-nas-filesystem 6d
Run the following command to query the details about the NAS file system:
kubectl get cnfs/cnfs-nas-filesystem -o yaml
Expected output:
Create a statically provisioned PV or a dynamic StorageClass and associate it with the NAS file system.
Create a statically provisioned PV.
Use the following template to create a statically provisioned PV and associate it with the NAS file system:
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: PersistentVolume metadata: name: cnfs-nas-pv labels: alicloud-pvname: cnfs-nas-pv spec: capacity: storage: 5Gi accessModes: - ReadWriteMany csi: driver: nasplugin.csi.alibabacloud.com volumeHandle: cnfs-nas-pv # The value must be the same as the PV name. volumeAttributes: containerNetworkFileSystem: cnfs-nas-filesystem path: "/" mountOptions: - nolock,tcp,noresvport - vers=3 EOF
Parameter
Description
containerNetworkFileSystem
The name of the CNFS file system that you want to use.
path
The path of the CNFS file system used by the PV.
Run the following command to check whether the PV is created:
kubectl get pv
Expected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE cnfs-nas-pv 5Gi RWX Retain Available 4s
Create a dynamic StorageClass.
Use the following template to create a dynamic StorageClass and associate it with the NAS file system:
cat <<EOF | kubectl apply -f - apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: alibabacloud-nas-cnfs mountOptions: - nolock,tcp,noresvport - vers=3 parameters: volumeAs: subpath containerNetworkFileSystem: nas-load-mount-target path: "/" provisioner: nasplugin.csi.alibabacloud.com reclaimPolicy: Retain allowVolumeExpansion: true EOF
NoteallowVolumeExpansion specifies whether to enable the Quota feature and volume expansion. Valid values: true and false.
Create PVCs.
Use the following template to create a PVC that is used to mount the NAS file system:
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: PersistentVolumeClaim metadata: name: cnfs-nas-pvc spec: accessModes: - ReadWriteMany storageClassName: alibabacloud-nas-cnfs resources: requests: storage: 70Gi EOF
Create an application.
Use the following template to create an application that uses the PVC:
cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata: name: cnfs-nas-deployment labels: app: nginx spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 volumeMounts: - name: cnfs-nas-pvc mountPath: "/data" volumes: - name: cnfs-nas-pvc persistentVolumeClaim: claimName: cnfs-nas-pvc EOF
Run the following command to query the status of the application:
kubectl get pod
Expected output:
NAME READY STATUS RESTARTS AGE cnfs-nas-deployment-86959b**** 1/1 Running 0 2s
The output shows that the created Deployment is in the Running state. This means that the CNFS file system is used by the Deployment.
Use the console
Create a CNFS file system.
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose
.On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the parameters and click OK.
Parameter
Description
Example
Name
The name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
The type of the file system that you want to host. NAS and OSS are supported.
NAS
Required
You can create a default NAS file system or select an existing NAS file system. If you select an existing NAS file system, you can select an existing NAS mount target or create a custom NAS file system.
Required is displayed only when Select File System Type is set to NAS.
Select Existing NAS File System
Select NAS File System
Select an existing NAS mount target or click Create NAS File System on the right side to create a custom NAS file system.
This option is displayed only when Required is set to Select Existing NAS File System.
Click Create NAS File System on the right side. You can create only general-purpose NAS file systems. For more information, see Create a General-purpose NAS file system in the NAS console.
Description
The description of the CNFS file system.
Use CNFS to create a custom NAS file system
End-to-end Data Acceleration
Specifies whether to use the elastic acceleration feature to mount the file system. By default, this feature is disabled. For more information about the elastic acceleration feature, see Enable the distributed caching feature of the CNFS client.
Disabled
Create a statically provisioned PV or a dynamic StorageClass and associate it with the NAS file system.
Create a statically provisioned PV.
On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose .
In the upper-right corner of the Persistent Volumes page, click Create.
In the Create PV panel, configure the parameters and click OK.
Parameter
Description
Example
PV Type
Valid values: Cloud Disk, NAS, and OSS. In this example, NAS is selected.
NAS
Volume Name
The name of the PV that you want to create. The name must be unique in the cluster.
cnfs-nas-pv
Capacity
The capacity claimed by the PVC. A NAS file system provides unlimited capacity. This parameter does not limit the storage usage of the NAS file system but defines the capacity of the PV.
5 Gi
Access Mode
You can select ReadWriteMany or ReadWriteOnce. Default value: ReadWriteMany.
ReadWriteMany
Enable CNFS
Enable CNFS. Perform the following operations after you enable CNFS:
Select the CNFS file system that you created in Step 1.
You can specify whether to enable CNFS acceleration. For more information about CNFS acceleration, see Enable the distributed caching feature of the CNFS client.
cnfs-nas-filesystem
Show Advanced Options
Mount Path: The mount path of the NAS file system. The mount path must start with a forward slash (/), which indicates the root directory. After you set this parameter, the PV is mounted to the specified subdirectory.
If the specified subdirectory does not exist, the system automatically creates the subdirectory in the NAS file system and mounts the subdirectory to the cluster.
If you do not set this parameter, the root directory of the NAS file system is mounted.
Reclaim Policy: the reclaim policy of the NAS file system. Only the Retain policy is supported.
/
Retain
Label
Add labels to the PV.
cnfs-nas-pv
Create a dynamic StorageClass.
On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose .
In the upper-right corner of the StorageClasses page, click Create.
In the Create panel, configure the parameters and click Create.
Parameter
Description
Example
Name
The name of the StorageClass.
The name must start with a lowercase letter, and can contain only lowercase letters, digits, periods (.), and hyphens (-).
alibabacloud-cnfs-nas
PV Type
Valid values: Cloud Disk and NAS.
NAS
Select Mount Target
Set the value to the mount target of the default NAS file system created in Step 1. For more information about how to view the mount target, see View mount targets.
64888******-e*****.cn-qingdao.nas.aliyuncs.com
Reclaim Policy
The reclaim policy of the NAS file system. Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained.
Retain
Mount Options
The mount options, such as the Network File System (NFS) version.
We recommend that you use NFS v3. Extreme NAS file systems support only NFS v3. For more information about the NFS protocol, see NFS.
nolock,tcp,noresvport
vers=3
Mount Path
The mount path of the NAS file system.
/
Create a persistent volume claim (PVC).
In the left-side navigation pane of the details page, choose .
In the upper-right corner of the Persistent Volume Claims page, click Create.
In the Create PVC panel, configure the parameters and click Create.
Parameter
Description
Example
PVC Type
Valid values: Cloud Disk, NAS, and OSS. In this example, NAS is selected.
NAS
Name
The name of the PVC. The name must be unique within the cluster.
cnfs-nas-pvc
Allocation Mode
The allocation mode of the volume.
Use StorageClass
Existing Storage Class
Click Select. Find the PV that you want to use and click Select in the Actions column.
alibabacloud-cnfs-nas
Capacity
The capacity claimed by the PVC.
NoteThe capacity claimed by the PVC cannot exceed the capacity of the PV that is bound to the PVC.
70 Gi
Access Mode
The access mode of the PVC. Default value: ReadWriteMany. You can also select ReadWriteOnce or ReadOnlyMany.
ReadWriteMany
Mount the PVC to the application.
Mount the NAS file system created by using CNFS to the /data path in the container.
Method 3: Create a CNFS file system by using an existing NAS file system
Use kubectl
Use CNFS to configure an existing NAS file system and use a statically or dynamically provisioned NAS volume to mount the existing NAS file system. Then, mount the statically or dynamically provisioned NAS volume to a Deployment.
Create a CNFS file system by using an existing NAS file system.
Use the following template to create a CNFS file system by using an existing NAS file system:
# Load the existing 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: 17f7e4****-h****.cn-beijing.nas.aliyuncs.com EOF
Parameter
Description
description
The description of the file system.
type
The type of the volume that you want to create.
reclaimPolicy
The reclaim policy of the NAS file system. Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained.
parameters.server
The URL of the mount target of the NAS file system.
Run the following command to query the NAS file system:
kubectl get cnfs
Expected output:
NAME AGE cnfs-nas-filesystem 6d
Run the following command to query the details about the NAS file system:
kubectl get cnfs/cnfs-nas-filesystem -o yaml
Expected output:
Use CNFS to create a NAS volume. For more information, see Step 2 to Step 4 in Method 2: Use CNFS to create a custom NAS file system.
Use the console
Create a CNFS file system.
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose
.On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the parameters and click OK.
Parameter
Description
Example
Name
The name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
The type of the file system that you want to host. NAS and OSS are supported.
NAS
Required
You can create a default NAS file system or select an existing NAS file system. If you select an existing NAS file system, you can select an existing NAS mount target or create a custom NAS file system.
Required is displayed only when Select File System Type is set to NAS.
Select Existing NAS File System
Select NAS File System
Select an existing NAS mount target or click Create NAS File System on the right side to create a custom NAS file system.
This option is displayed only when Required is set to Select Existing NAS File System.
Select an existing NAS mount target. For more information about how to view the mount target, see View mount targets.
Description
The description of the CNFS file system.
Use CNFS to create a custom NAS file system
End-to-end Data Acceleration
Specifies whether to use the elastic acceleration feature to mount the file system. By default, this feature is disabled. For more information about the elastic acceleration feature, see Enable the distributed caching feature of the CNFS client.
Disabled
Use CNFS to create a NAS volume. For more information, see Step 2 to Step 4 in Method 2: Use CNFS to create a custom NAS file system.
What to do next
For more information about how to monitor NAS resources on the node side, see Examples of NAS file system monitoring.