Container Network File System (CNFS) represents File Storage NAS file systems as Kubernetes CustomResourceDefinitions (CRDs), giving you Kubernetes-native control over file system creation, deletion, mounting, monitoring, and expansion. CNFS also improves performance and Quality of Service (QoS) for NAS file systems in your cluster.
This topic covers three ways to provision CNFS with NAS: creating a default file system, creating a custom file system, and importing an existing file system.
Limitations
Only Capacity NAS and Performance NAS file systems are supported. Advanced NAS and Extreme NAS file systems are not supported.
The CNFS
reclaimPolicyonly supportsRetain. Deleting a CNFS resource does not delete the underlying NAS file system.Default file systems are not encrypted. To enable SSE-KMS encryption, specify
encryptType: SSE-KMSin the CNFS spec.Activate Key Management Service (KMS) before encrypting NAS file systems. See Purchase a dedicated KMS instance.
Choose a method
Method | Description | Provisioning |
Create a default NAS file system | CNFS creates a Capacity or Performance NAS file system automatically in the cluster VPC. Simplest setup. | Dynamic |
Create a custom NAS file system | Specify storage type, encryption, vSwitch, and recycle bin settings. | Static or dynamic |
Import an existing NAS file system | Register an existing NAS file system as a CNFS resource. | Static or dynamic |
Prerequisites
Before you begin, make sure that you have:
An activated NAS service. Visit the NAS product page to activate it.
An ACK Pro cluster running Kubernetes later than 1.20. For kubectl-based CNFS, Kubernetes 1.20 is also supported. See Create an ACK managed cluster.
The following components updated to the latest version. See Manage components.
Component | Minimum version |
csi-plugin | 1.20.5-ff6490f-aliyun |
csi-provisioner | 1.20.5-ff6490f-aliyun |
storage-operator (kubectl) | 1.18.8.56-2aa33ba-aliyun |
storage-operator (console) | 1.26.2-1de13b6-aliyun |
(kubectl only) A configured kubectl connection to the cluster. See Connect to an ACK cluster using kubectl.
Method 1: Create a default NAS file system
CNFS creates a Capacity or Performance NAS file system in the virtual private cloud (VPC) where the cluster is deployed. If the region does not support Capacity NAS, a Performance NAS file system is created instead.
Extreme NAS file systems are not supported. The default file system is not encrypted.
kubectl
Apply the following manifests to create a CNFS resource, StorageClass, PVC, Deployment, and StatefulSet.
# 1. CNFS resource - creates a NAS file system automatically
apiVersion: storage.alibabacloud.com/v1beta1
kind: ContainerNetworkFileSystem
metadata:
name: cnfs-nas-filesystem
spec:
description: "cnfs"
type: nas
reclaimPolicy: Retain
parameters:
# encryptType: SSE-KMS # Optional. Uncomment to enable KMS encryption.
# enableTrashCan: "true" # Optional. Uncomment to enable the recycle bin.
---
# 2. StorageClass - binds to the CNFS file system
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: alibabacloud-cnfs-nas
mountOptions:
- nolock,tcp,noresvport
- vers=3
parameters:
volumeAs: subpath
containerNetworkFileSystem: cnfs-nas-filesystem
path: "/"
provisioner: nasplugin.csi.alibabacloud.com
reclaimPolicy: Retain
allowVolumeExpansion: true # Optional. Set to true to enable volume expansion.
---
# 3. PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: cnfs-nas-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: alibabacloud-cnfs-nas
resources:
requests:
storage: 70Gi # With directory quota enabled, limits the writable size to 70 GiB.
---
# 4. Deployment
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
volumeMounts:
- mountPath: "/data"
name: cnfs-nas-pvc
volumes:
- name: cnfs-nas-pvc
persistentVolumeClaim:
claimName: cnfs-nas-pvc
---
# 5. StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cnfs-nas-sts
labels:
app: nginx
spec:
serviceName: "nginx"
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
volumeMounts:
- mountPath: "/data"
name: www
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "alibabacloud-cnfs-nas"
resources:
requests:
storage: 50Gi # With directory quota enabled, limits the writable size to 50 GiB.CNFS parameters
Parameter | Description | Required | Default |
| Description of the file system. | No | None |
| Volume type. Set to | Yes | None |
| Reclaim policy. Only | Yes | None |
| Encryption method. Valid values: | No |
|
| Whether to enable the recycle bin. Valid values: | No |
|
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 Volumes > CNFS.
On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the following parameters and click OK.
Parameter
Description
Example
Name
Name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
File system type. Select NAS.
NAS
Required
Select Create Default NAS File System. This field is displayed only when Select File System Type is set to NAS.
Create Default NAS File System
Description
Description of the CNFS file system.
Default NAS file system
End-to-end Data Acceleration
Whether to enable elastic acceleration for mounting. Disabled by default. See Enable the distributed caching feature of the CNFS client.
Disabled
On the Container Network File System (CNFS) page, click the CNFS file system name to view its 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, hover over the
icon in the Mount Target column to view the mount target.
Create a StorageClass.
On the Clusters page, find the cluster and click its name. In the left-side pane, choose Volumes > StorageClasses.
In the upper-right corner of the StorageClasses page, click Create.
In the Create panel, configure the following parameters and click Create.
Parameter
Description
Example
Name
Name of the StorageClass. Must start with a lowercase letter. Can contain lowercase letters, digits, periods (.), and hyphens (-).
alibabacloud-cnfs-nas
PV Type
Volume type. Select NAS.
NAS
Select Mount Target
Mount target of the NAS file system created in Step 1. See View mount targets.
64888****-e*.cn-qingdao.nas.aliyuncs.comReclaim Policy
Reclaim policy. Only Retain is supported.
Retain
Mount Options
NFS mount options. Use NFS v3. See NFS.
nolock,tcp,noresvport vers=3Mount Path
Mount path of the NAS file system.
/
Create a PVC.
In the left-side navigation pane, choose Volumes > Persistent Volume Claims.
In the upper-right corner, click Create.
In the Create PVC panel, configure the following parameters and click Create.
Parameter
Description
Example
PVC Type
Volume type. Select NAS.
NAS
Name
PVC name. Must be unique within the cluster.
cnfs-nas-pvc
Allocation Mode
Select Use StorageClass.
Use StorageClassExisting Storage Class
Click Select, find the StorageClass, and click Select in the Actions column.
alibabacloud-cnfs-nas
Capacity
Capacity claimed by the PVC. Cannot exceed the PV capacity.
70 Gi
Access Mode
Access mode. Default: ReadWriteMany. Also supports ReadWriteOnce and ReadOnlyMany.
ReadWriteMany
Mount the PVC to the application. Mount the NAS file system created by CNFS to the
/datapath in the container.
Method 2: Create a custom NAS file system
Specify storage type, encryption, recycle bin retention, and vSwitch when creating the NAS file system.
kubectl
Create a custom NAS file system. #### CNFS parameters
Parameter
Description
Required
Default
descriptionDescription of the file system.
No
None
typeVolume type. Set to
nas.Yes
None
reclaimPolicyReclaim policy. Only
Retainis supported.Yes
None
parameters.filesystemTypeFile system type.
standardindicates General-purpose NAS.No
standardparameters.storageTypeStorage type. Valid values:
Performance,Capacity.No
None
parameters.protocolTypeFile transfer protocol. Only
NFS(NFSv3) is supported.No
NFSparameters.encryptTypeEncryption method. Valid values:
None,SSE-KMS.No
Noneparameters.enableTrashCanWhether to enable the recycle bin. Valid values:
true,false.No
falseparameters.trashCanReservedDaysMaximum number of days files are retained in the recycle bin.
No
7parameters.vSwitchIdvSwitch ID for the NAS file system.
No
None
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**** EOFVerify the file system. Query the CNFS resource: Expected output: View file system details:
Expected output #### Status fields
Field
Description
status.statusCNFS status. Valid values:
Pending,Creating,Initialization,Available,Unavailable,Fatal,Terminating.conditions.lastProbeTimeTime of the last probe.
conditions.reasonReason for the current state.
conditions.statusWhether the file system is ready. Valid values:
Ready,NotReady.fsAttributes.accessGroupNamePermission group for the mount target. Value:
DEFAULT_VPC_GROUP_NAME(default VPC permission group).fsAttributes.encryptTypeEncryption method. Valid values:
None,SSE-KMS.fsAttributes.enableTrashCanWhether the recycle bin is enabled. Valid values:
true,false.fsAttributes.filesystemIdFile system ID.
fsAttributes.filesystemTypeFile system type.
standardindicates General-purpose NAS.fsAttributes.protocolTypeFile transfer protocol.
fsAttributes.regionIdRegion of the CNFS file system.
fsAttributes.serverDomain name of the mount target.
fsAttributes.storageTypeStorage type. Valid values:
Performance,Capacity.fsAttributes.vSwitchIdvSwitch used by the CNFS file system.
fsAttributes.vpcIdVPC of the CNFS file system.
fsAttributes.zoneIdZone of the CNFS file system.
kubectl get cnfsNAME AGE cnfs-nas-filesystem 6dkubectl get cnfs/cnfs-nas-filesystem -o yamlapiVersion: 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 vSwitchId: vsw-XXX enableTrashCan: "true" status: conditions: - lastProbeTime: "2021-05-14 16:20:15" reason: The nas filesystem and mount target complete initialization. status: Ready fsAttributes: accessGroupName: DEFAULT_VPC_GROUP_NAME encryptType: SSE-KMS enableTrashCan: "true" filesystemId: 17f7e48ece filesystemType: standard protocolType: NFS regionId: cn-beijing server: 17f7e48ece-h****.cn-beijing.nas.aliyuncs.com storageType: Capacity vSwitchId: vsw-2ze9l3ppwzg6bl02j**** vpcId: vpc-2ze9sgmehjvwv5x74**** zoneId: cn-beijing-h status: AvailableCreate a PV or StorageClass to associate with the NAS file system. Choose one of the following options. #### Option A: Create a static PV Verify the PV: Expected output: #### Option B: Create a dynamic StorageClass
allowVolumeExpansionenables the directory quota feature and volume expansion. Valid values:true,false.Parameter
Description
containerNetworkFileSystemName of the CNFS file system.
pathMount path of the NAS file system used by the PV.
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 # Must match the PV name. volumeAttributes: containerNetworkFileSystem: cnfs-nas-filesystem path: "/" mountOptions: - nolock,tcp,noresvport - vers=3 EOFkubectl get pvNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE cnfs-nas-pv 5Gi RWX Retain Available 4scat <<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: cnfs-nas-filesystem path: "/" provisioner: nasplugin.csi.alibabacloud.com reclaimPolicy: Retain allowVolumeExpansion: true # Set to true to enable the directory quota feature and volume expansion. EOFCreate a PVC.
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 EOFCreate an application. Verify the application: Expected output: The
Runningstatus confirms that the CNFS file system is mounted to the Deployment.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 EOFkubectl get podNAME READY STATUS RESTARTS AGE cnfs-nas-deployment-86959b**** 1/1 Running 0 2s
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 Volumes > CNFS.
On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the following parameters and click OK.
Parameter
Description
Example
Name
Name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
File system type. Select NAS.
NAS
Required
Select Select Existing NAS File System. This field is displayed only when Select File System Type is set to NAS.
Select Existing NAS File SystemSelect NAS File System
Select an existing NAS mount target, or click Create NAS File System to create a custom General-purpose NAS file system. Displayed only when Required is set to Select Existing NAS File System. See Create a General-purpose NAS file system.
Click Create NAS File SystemDescription
Description of the CNFS file system.
Custom NAS file system
End-to-end Data Acceleration
Whether to enable elastic acceleration for mounting. Disabled by default. See Enable the distributed caching feature of the CNFS client.
Disabled
Create a PV or StorageClass to associate with the NAS file system.
To create a static PV:
On the Clusters page, find the cluster and click its name. In the left-side pane, choose Volumes > Persistent Volumes.
In the upper-right corner, click Create.
In the Create PV panel, configure the following parameters and click OK.
Parameter
Description
Example
PV Type
Volume type. Select NAS.
NAS
Volume Name
PV name. Must be unique in the cluster.
cnfs-nas-pv
Capacity
PV capacity. Does not limit NAS storage usage.
5 Gi
Access Mode
Access mode. Default: ReadWriteMany. Also supports ReadWriteOnce.
ReadWriteManyEnable CNFS
Enable CNFS and select the CNFS file system created in Step 1. Optionally enable CNFS acceleration. See Enable the distributed caching feature of the CNFS client.
cnfs-nas-filesystemShow Advanced Options
Mount Path: Must start with a forward slash (/). If the subdirectory does not exist, the system creates it automatically. Defaults to root (/).
Reclaim Policy: Only Retain is supported./,RetainLabel
Labels for the PV.
cnfs-nas-pv
To create a dynamic StorageClass:
On the Clusters page, find the cluster and click its name. In the left-side pane, choose Volumes > StorageClasses.
In the upper-right corner, click Create.
In the Create panel, configure the following parameters and click Create.
Parameter
Description
Example
Name
Name of the StorageClass. Must start with a lowercase letter. Can contain lowercase letters, digits, periods (.), and hyphens (-).
alibabacloud-cnfs-nas
PV Type
Volume type. Select NAS.
NAS
Select Mount Target
Mount target of the NAS file system created in Step 1. See View mount targets
64888****-e*.cn-qingdao.nas.aliyuncs.comReclaim Policy
Reclaim policy. Only Retain is supported.
Retain
Mount Options
NFS mount options. Use NFS v3. See NFS.
nolock,tcp,noresvport vers=3Mount Path
Mount path of the NAS file system.
/
Create a PVC.
In the left-side navigation pane, choose Volumes > Persistent Volume Claims.
In the upper-right corner, click Create.
In the Create PVC panel, configure the following parameters and click Create.
Parameter
Description
Example
PVC Type
Volume type. Select NAS.
NAS
Name
PVC name. Must be unique within the cluster.
cnfs-nas-pvcAllocation Mode
Select Use StorageClass.
Use StorageClassExisting Storage Class
Click Select, find the StorageClass, and click Select in the Actions column.
alibabacloud-cnfs-nasCapacity
Capacity claimed by the PVC. Cannot exceed the PV capacity.
70 Gi
Access Mode
Access mode. Default: ReadWriteMany. Also supports ReadWriteOnce and ReadOnlyMany.
ReadWriteMany
Mount the PVC to the application. Mount the NAS file system created by CNFS to the
/datapath in the container.
Method 3: Import an existing NAS file system
Register an existing NAS file system as a CNFS resource and mount it to workloads.
kubectl
Create a CNFS resource from an existing NAS file system.
Parameter
Description
Required
descriptionDescription of the file system.
No
typeVolume type. Set to
nas.Yes
reclaimPolicyReclaim policy. Only
Retainis supported.Yes
parameters.serverMount target URL of the existing NAS file system.
Yes
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 EOFVerify the file system. Expected output: View file system details:
Expected output
kubectl get cnfsNAME AGE cnfs-nas-filesystem 6dkubectl get cnfs/cnfs-nas-filesystem -o yamlapiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerNetworkFileSystem metadata: name: cnfs-nas-filesystem spec: description: cnfs parameters: server: 17f7e48ece-h****.cn-beijing.nas.aliyuncs.com reclaimPolicy: Retain type: nas status: conditions: - lastProbeTime: "2021-05-14 16:20:15" reason: The nas filesystem and mount target complete initialization. status: Ready fsAttributes: accessGroupName: DEFAULT_VPC_GROUP_NAME encryptType: None enableTrashCan: "true" filesystemId: 17f7e4**** filesystemType: standard protocolType: NFS regionId: cn-beijing server: 17f7e48ece-h****.cn-beijing.nas.aliyuncs.com storageType: Capacity vSwitchId: vsw-2ze9l3ppwzg6bl02j**** vpcId: vpc-2ze9sgmehjvwv5x74**** zoneId: cn-beijing-h status: AvailableCreate a NAS volume and mount it to a workload. Follow Steps 3 through 5 in Method 2 to create a PV or StorageClass, PVC, and application.
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 Volumes > CNFS.
On the Container Network File System (CNFS) page, click Create CNFS File System.
In the Create CNFS File System panel, configure the following parameters and click OK.
Parameter
Description
Example
Name
Name of the CNFS file system.
cnfs-nas-filesystem
Select File System Type
File system type. Select NAS.
NAS
Required
Select Select Existing NAS File System. This field is displayed only when Select File System Type is set to NAS.
Select Existing NAS File SystemSelect NAS File System
Select an existing NAS mount target. See View mount targets.
Select an existing NAS mount targetDescription
Description of the CNFS file system.
Existing NAS file system
End-to-end Data Acceleration
Whether to enable elastic acceleration for mounting. Disabled by default. See Enable the distributed caching feature of the CNFS client.
Disabled
Create a NAS volume and mount it to a workload. Follow Steps 2 through 4 in the Method 2 console instructions to create a PV or StorageClass, PVC, and mount the PVC to the application.
Next steps
Monitor NAS resource usage at the node level. See Examples of NAS file system monitoring.