All Products
Search
Document Center

File Storage NAS:Use CNFS to manage NAS file systems

Last Updated:Nov 05, 2024

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

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

  1. Run the following command to use CNFS to create and manage a Capacity NAS file system.

    Note
    • Capacity 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
  2. Run the following command to query NAS file systems managed by CNFS:

    kubectl get cnfs cnfs-nas-filesystem -oyaml

    Expected output:

    Click to view details

    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"storage.alibabacloud.com/v1beta1","kind":"ContainerNetworkFileSystem","metadata":{"annotations":{},"name":"cnfs-nas-filesystem"},"spec":{"description":"cnfs","parameters":{"enableTrashCan":"true","encryptType":"None","filesystemType":"standard","protocolType":"NFS","storageType":"Capacity","trashCanReservedDays":"5"},"reclaimPolicy":"Retain","type":"nas"}}
      creationTimestamp: "2022-12-14T13:09:59Z"
      finalizers:
      - protection.alibabacloud.com/cnfs
      generation: 6
      name: cnfs-nas-filesystem
      resourceVersion: "20362768"
      uid: f70edfc7-2760-4304-a693-a682bfc1****
    spec:
      description: cnfs
      parameters:
        enableTrashCan: "true"
        encryptType: None
        filesystemType: standard
        protocolType: NFS
        storageType: Capacity
        trashCanReservedDays: "5"
      reclaimPolicy: Retain
      type: nas
    status:
      conditions:
      - lastProbeTime: "2022-12-14 21:10:33"
        reason: The nas filesystem and mount target complete initialization.
        status: Ready
      fsAttributes:
        accessGroupName: DEFAULT_VPC_GROUP_NAME
        enableTrashCan: "true"
        encryptType: None
        filesystemId: 971134b0e8
        filesystemType: standard
        protocolType: NFS
        regionId: cn-zhangjiakou
        server: 971134b0e8-****.cn-zhangjiakou.nas.aliyuncs.com
        storageType: Capacity
        trashCanReservedDays: "5"
        useClient: "NFSClient"
        vSwitchId: vsw-8vb4m54nru36mdv2s****
        vpcId: vpc-8vbv553d3rdcwwin3****
      status: Available

Method 2: Use CNFS to manage an existing NAS file system

Note

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.

  1. 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
  2. Run the following command to query NAS file systems managed by CNFS:

    kubectl get cnfs cnfs-nas-filesystem -oyaml

    Expected output:

    Click to view details

    apiVersion: storage.alibabacloud.com/v1beta1
    kind: ContainerNetworkFileSystem
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"storage.alibabacloud.com/v1beta1","kind":"ContainerNetworkFileSystem","metadata":{"annotations":{},"name":"cnfs-nas-filesystem"},"spec":{"server: 971134b0e8-jsg4.cn-zhangjiakou.nas.aliyuncs.com"}}}
      creationTimestamp: "2022-12-14T13:09:59Z"
      finalizers:
      - protection.alibabacloud.com/cnfs
      generation: 6
      name: cnfs-nas-filesystem
      resourceVersion: "20362768"
      uid: f70edfc7-2760-4304-a693-a682bfc1****
    spec:
      description: cnfs
      parameters:
        server: 971134b0e8-****.cn-zhangjiakou.nas.aliyuncs.com
      reclaimPolicy: Retain
      type: nas
    status:
      conditions:
      - lastProbeTime: "2022-12-14 21:10:33"
        reason: The nas filesystem and mount target complete initialization.
        status: Ready
      fsAttributes:
        accessGroupName: DEFAULT_VPC_GROUP_NAME
        enableTrashCan: "true"
        encryptType: None
        filesystemId: 971134b0e8
        filesystemType: standard
        protocolType: NFS
        regionId: cn-zhangjiakou
        server: 971134b0e8-****.cn-zhangjiakou.nas.aliyuncs.com
        storageType: Capacity
        trashCanReservedDays: "5"
        useClient: "NFSClient"
        vSwitchId: vsw-8vb4m54nru36mdv2s****
        vpcId: vpc-8vbv553d3rdcwwin3x****
      status: Available

References