Container Network File System (CNFS) lets you manage NAS file systems as native Kubernetes objects that you can create and use declaratively. This provides simple, efficient persistent volumes for workloads like websites and data analytics and supports various use cases such as data sharing and isolation.
Prerequisites
An ACK Pro managed cluster of version 1.20 or later is required. To upgrade the cluster, see Manually upgrade a cluster.
Kubectl management of CNFS requires version 1.20 or later.
The following storage add-on versions are required. To upgrade the components, see Components.
csi-plugin and csi-provisioner: v1.24.11-5221f79-aliyun or later.
storage-operator: v1.26.2-1de13b6-aliyun or later.
The File Storage NAS service must be activated. The following limits apply to NAS file systems. For more information, see Limitations.
Only General Purpose NAS file systems of the Capacity, Performance, and Premium types are supported; Extreme NAS is not.
There is an upper limit on the number of NAS file systems that you can create per account in a single region.
To use KMS encryption for a NAS file system, activate the KMS service. For more information, see Activate Key Management Service.
Create a NAS file system
Create and use a NAS file system
Before you begin, choose how to provide a NAS file system for your cluster.
Method | Description | Volume provisioning method | Use cases |
CNFS automatically creates and manages a NAS file system with a fixed configuration for fast mounts. | dynamic volume |
| |
CNFS creates a new, customizable NAS file system based on the parameters you specify. |
| When you have specific requirements for performance, encryption, or cost, or need fine-grained storage management. | |
CNFS integrates an existing NAS file system for centralized management. |
| For integrating an existing NAS file system into your cluster. |
Method 1: Automatically create a NAS file system
You can use Container Network File System (CNFS) to automatically create a NAS file system with a default configuration. CNFS creates the file system based on your cluster environment. By default, the file system is not encrypted. If Capacity NAS is not supported in the current region, a Performance NAS file system is created instead.
After you create a CNFS resource and a StorageClass, your workload can request storage by using a PersistentVolumeClaim (PVC). This dynamically creates a PersistentVolume (PV) on the NAS file system and mounts it to a Pod.
kubectl
1. Create a CNFS Create a |
|
2. Create a StorageClass Create a | |
3. Create a PVC The application requests a volume by using a PVC and references the StorageClass as its configuration template. | |
4. Create an application and mount the PVC After the PVC is created, deploy a sample application, such as a Deployment or a StatefulSet, and mount the PV bound to the PVC to the application. |
|
5. Verify the results |
|
Console
1. Create a CNFS |
|
2. Create a StorageClass |
|
3. Create a PVC |
|
4. Create an application and mount the NAS file system | When creating a Deployment or a StatefulSet, you can mount a PVC to a container in the Volumes section of the Container page. The following example shows how to mount the NAS file system created using CNFS to the /data path in a container. Configuration details: Set Volume Type to Cloud Storage, select the corresponding CNFS NAS PVC (for example, |
Method 2: Create a custom NAS file system
Use Container Network File System (CNFS) to create a NAS file system with custom parameters.
Define a
ContainerNetworkFileSystemresource to provision a new NAS file system.Make the file system available to applications in the cluster by creating a static persistent volume (PV) or a dynamic StorageClass.
kubectl
1. Create a custom NAS file system Create a |
|
2. Create a PV or StorageClass After you create the CNFS, choose how your application will connect to and use the NAS file system.
| Static PVFor more information about PV parameters, see Use static NAS volumes. Dynamic StorageClassFor more information about StorageClass parameters, see Use dynamic NAS volumes. |
3. Create a PVC Create a persistent volume claim (PVC) that references the NAS file system based on the static persistent volume or dynamic StorageClass you created earlier. | Static PVDynamic StorageClass |
4. Create an application and mount the NAS file system After the persistent volume claim (PVC) is created, mount the bound PV to your application. | |
5. Verify the result |
|
Console
|
|
| PV
StorageClass
|
|
|
| When creating a Deployment or a StatefulSet, you can mount a PVC to a container in the Volumes section of the Container page. The following example shows how to mount the NAS file system created using CNFS to the /data path in a container. Configuration details: Set Volume Type to Cloud Storage, select the corresponding CNFS NAS PVC (for example, |
Method 3: Use an existing NAS file system
Use CNFS to connect an existing NAS file system to your cluster, making it available for applications.
kubectl
1. Create a CNFS for an existing NAS file system Create a |
|
2. Create a PV or StorageClass After you create the CNFS, choose how your application will connect to and use the NAS file system.
| Static PVFor more information about PV parameters, see Use static NAS volumes. Dynamic StorageClassFor more information about StorageClass parameters, see Use dynamic NAS volumes. |
3. Create a PVC Create a persistent volume claim (PVC) that references the NAS file system based on the static persistent volume or dynamic StorageClass you created earlier. | Static PVDynamic StorageClass |
4. Create an application and mount the NAS file system After the persistent volume claim (PVC) is created, mount the bound PV to your application. | |
5. Verify the result |
|
Console
|
|
| PV
StorageClass
|
|
|
| When creating a Deployment or a StatefulSet, you can mount a PVC to a container in the Volumes section of the Container page. The following example shows how to mount the NAS file system created using CNFS to the /data path in a container. Configuration details: Set Volume Type to Cloud Storage, select the corresponding CNFS NAS PVC (for example, |
Configure shared and isolated storage
After creating a NAS file system, you can configure it for shared or isolated storage to meet your application's requirements.
Configure a shared NAS volume
To share data between Pods, mount the same directory from a NAS file system to multiple Pods as a shared volume.
How it works: This method uses a static volume. The
pathspecified in the PersistentVolume (PV) is the exact directory that the CSI driver mounts. When multiple Pods mount this PV using the same PersistentVolumeClaim (PVC), they all access the same directory, which enables data sharing.Key configuration: In the
volumessection of your workload's Pod template (.spec.template), set thepersistentVolumeClaim.claimNameparameter to the same PVC name.
1. Create a PV and PVC that point to a specific directory | |
2. Create a sample Deployment | |
3. Verify the result |
Configure an isolated NAS volume
For use cases requiring data isolation, such as multi-tenancy, you can provide each Pod or group of Pods with a dedicated storage directory.
How it works: This method uses a dynamic volume. The CSI driver automatically creates a dedicated subdirectory with the same name as the PV under the specified
pathto serve as the mount point. Because each PVC binds to a separate subdirectory, this ensures data isolation.Key configuration:
In the
parameterssection of your StorageClass, ensurevolumeAs: subpathis set. This setting (which is the default) creates a dedicated subdirectory for each PVC.In the StatefulSet definition, use the
volumeClaimTemplatessection to automatically create and bind a unique PVC for each Pod.
1. Create a StorageClass for dynamic subdirectory creation | |
2. Create a sample StatefulSet | |
3. Verify the result |
Production recommendations
Data security
Data encryption: When creating a new NAS file system, set
encryptType: SSE-KMSin theparametersof the CNFS object. This enables server-side encryption and improves data security.Data protection and reclaim policy: The
reclaimPolicyfor a CNFS object is alwaysRetain, which means deleting the CNFS object in Kubernetes does not delete the backend NAS instance. However, the reclaim policy for a PV is defined by its StorageClass. For production environments, set the reclaim policy toRetainto prevent accidental data loss.Recycle bin: When creating a NAS file system, enable the recycle bin by setting
enableTrashCan: "true"to prevent accidental data deletion.Concurrent writes: When multiple Pods mount the same shared storage volume, avoid multiple application instances writing to the same file at the application level. This prevents file corruption from concurrent writes.
Operations and management
Performance isolation: Isolated storage volumes only provide data-level isolation. All isolated volumes share the IOPS and throughput of the same backend NAS instance. For core applications with strict I/O performance requirements and a need for stable latency, provision a dedicated NAS file system.
Capacity management: Set
allowVolumeExpansion: truein your StorageClass to allow for the expansion of the storage volume's directory quota.The value of
requests.storagein a PVC is primarily used for scheduling decisions and does not set a hard quota on the entire NAS file system.Monitoring and alerting: Use Container Storage Monitoring to configure alerts for key metrics such as capacity utilization, IOPS, and throughput of your NAS file system. This helps you promptly identify capacity or performance bottlenecks.
Cost optimization
Choose the right storage type: Select a NAS type based on your cost and performance requirements. For guidance, see Select a NAS type. For example, Capacity NAS is a lower-cost option suitable for latency-insensitive tasks such as file sharing or archiving.
Release resources promptly: After decommissioning an application, release all unused resources. Also, delete the backend NAS file system if it is no longer needed to avoid unexpected costs.
References
Verify shared storage, data isolation, and persistent storage
After the NAS file system is mounted, verify that the storage behaves as expected.
Verify shared and persistent storage for a deployment
Verify data isolation and persistent storage for a StatefulSet
CNFS YAML
Run kubectl get cnfs/<cnfsName> -o yaml to view the complete configuration and real-time status of the CNFS object.
This section provides an example of running the kubectl get cnfs/cnfs-nas-filesystem -o yaml command in Method 2 to view the cnfs-nas-filesystem YAML.
YAML example
Parameters
Resource cleanup
To avoid unexpected charges and ensure data security, follow these steps to release resources that are no longer in use.
Delete the workload
Action: Delete all applications that use the relevant PVCs, such as deployments and StatefulSets. This action stops the pods and unmounts the volumes.
Example command:
kubectl delete deployment <YOUR-DEPLOYMENT-NAME>
Delete the PVCs
Action: Delete the PVC associated with the application. The result of the PV deletion depends on the reclaim policy (
reclaimPolicy).Retain(Recommended): After you delete the PVC, the data and directories on the backend NAS are completely retained.Delete: When a PVC is deleted, its bound PV is also deleted. The data and directories on the backend NAS will be handled based on the setting of thearchiveOnDeleteparameter in theStorageClass."true"(default): The directory or file is not actually deleted. Instead, it is renamed toarchived-{pvName}.{timestamp}."false": Data is permanently deleted. This operation is irreversible. Use with caution.
Example command:
kubectl delete pvc <YOUR-PVC-NAME>
Delete the PV
Operation: Delete the PV. This operation is primarily for static PVs or for PVs that are in the
Releasedstate after theRetainpolicy is used in the previous step.This action only removes the resource definition from Kubernetes. It does not delete the data on the backend NAS.
Example command:
kubectl delete pv <YOUR-PV-NAME>
Delete Kubernetes storage definitions (Optional)
Action: Delete the StorageClass and CNFS objects that are no longer needed.
This action only removes the resource definitions from Kubernetes. It does not delete the data on the backend NAS.
Example commands:
kubectl delete sc <YOUR-STORAGECLASS-NAME>andkubectl delete cnfs <YOUR-CNFS-NAME>
Delete the backend NAS file system
Action: See Delete a file system. This irreversible action permanently deletes all data on the NAS. Use with extreme caution. Before you proceed, ensure that no other services depend on this NAS file system.