All Products
Search
Document Center

File Storage NAS:Use CNFS to manage NAS file systems

Last Updated:Nov 14, 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 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

Important

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.

View the YAML files that are used to create CNFS, StorageClasses, and workloads

# Create the following objects: a CNFS, a StorageClass, a Deployment, and a StatefulSet. 
cat << EOF | kubectl apply -f -
apiVersion: storage.alibabacloud.com/v1beta1
kind: ContainerNetworkFileSystem
metadata:
  name: cnfs-nas-filesystem
spec:
  description: "cnfs"
  type: nas
  reclaimPolicy: Retain # Only the Retain policy is supported. If the CNFS file system is deleted, the related NAS file system is retained. 
  parameters:
    encryptType: SSE-KMS # This parameter is optional. If you leave this parameter empty, the created NAS file system is not encrypted. A value of SSE-KMS indicates that the created NAS file system is encrypted by KMS. 
    enableTrashCan: "true" # This parameter is optional. If you leave this parameter empty, the recycle bin feature is disabled. A value of true indicates that the recycle bin feature is enabled. 
---
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 # This parameter is optional. A value of true indicates that the NAS file system can be expanded. 
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cnfs-nas-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: alibabacloud-cnfs-nas
  resources:
    requests:
      storage: 70Gi # If you enable the directory quota feature, the storage field takes effect. A value of 70Gi indicates that the maximum size of data that can be written into a dynamically created directory is 70 GiB. 
---
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
---
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 # If you enable the directory quota feature, the storage field takes effect. A value of 50Gi indicates that the maximum size of data that can be written into a dynamically created directory is 50 GiB. 
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.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.

Use the console

  1. Create a CNFS file system.

    1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

    2. On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose Volumes > Container Network File System (CNFS).

    3. On the Container Network File System (CNFS) page, click Create CNFS File System.

    4. 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

    5. 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.

    6. On the File System List page, click the Mount Targets tab. In the Mount Target list, move the pointer over the image.pngicon in the Mount Target column to view the mount target.

  2. Create a dynamic StorageClass.

    1. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose Volumes > StorageClasses.

    2. In the upper-right corner of the StorageClasses page, click Create.

    3. 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.

      /

  3. Create a persistent volume claim (PVC).

    1. In the left-side navigation pane of the details page, choose Volumes > Persistent Volume Claims.

    2. In the upper-right corner of the Persistent Volume Claims page, click Create.

    3. 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.

      Note

      The 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

  4. Mount the PVC to the application.

    Mount the NAS file system created by using CNFS to the /data path in the container.

    image

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.

  1. Create a custom NAS file system.

    1. 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.

    2. Run the following command to query the created NAS file system:

      kubectl get cnfs

      Expected output:

      NAME                  AGE
      cnfs-nas-filesystem   6d
    3. Run the following command to query the details about the NAS file system:

      kubectl get cnfs/cnfs-nas-filesystem -o yaml

      Expected output:

      View expected output

      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":"filesystem4","parameters":{"filesystemId":"17f7e4****","server":"17f7e4****-h****.cn-beijing.nas.aliyuncs.com"},"reclaimPolicy":"Retain","type":"nas"}}
        creationTimestamp: "2021-05-14T08:20:09Z"
        finalizers:
        - protection.alibabacloud.com/cnfs
        generation: 6
        name: cnfs-nas-filesystem
        resourceVersion: "122342382"
        uid: a9e9650c-68b2-405b-8274-0f5b6063****
      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: Available

      Parameter

      Description

      status

      The status of the CNFS. Valid values: Pending, Creating, Initialization, Available, Unavailable, Fatal, and Terminating.

      conditions.lastProbeTime

      The time when the last probe was sent.

      conditions.reason

      The reason for the current state.

      conditions.status

      Indicates whether the file system is ready. Valid values: Ready and NotReady.

      fsAttributes.accessGroupName

      The name of the permission group used by the mount target. Set the value to DEFAULT_VPC_GROUP_NAME. This indicates the default permission group for VPCs.

      fsAttributes.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.

      fsAttributes.enableTrashCan

      Specifies whether to enable the recycle bin feature.

      • true: enables the recycle bin feature.

      • false: disables the recycle bin feature.

      fsAttributes.filesystemId

      The ID of the file system.

      fsAttributes.filesystemType

      The type of the file system. Default value: standard. The default value indicates the General-purpose NAS type.

      fsAttributes.protocolType

      The file transfer protocol. NFS is supported.

      fsAttributes.regionId

      The region to which the CNFS file system belongs.

      fsAttributes.server

      The domain name of the mount target of the CNFS file system.

      fsAttributes.storageType

      The storage type. If you set filesystemType to standard, the valid values are Performance and Capacity.

      fsAttributes.vSwitchId

      The vSwitch used by the CNFS file system.

      fsAttributes.vpcId

      The VPC to which the CNFS file system belongs.

      fsAttributes.zoneId

      The zone to which the CNFS file system belongs.

  2. Create a statically provisioned PV or a dynamic StorageClass and associate it with the NAS file system.

    • Create a statically provisioned PV.

      1. 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.

      2. 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
      Note

      allowVolumeExpansion specifies whether to enable the Quota feature and volume expansion. Valid values: true and false.

  3. Create PVCs.

    1. 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
  4. Create an application.

    1. 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
    2. 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

  1. Create a CNFS file system.

    1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

    2. On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose Volumes > Container Network File System (CNFS).

    3. On the Container Network File System (CNFS) page, click Create CNFS File System.

    4. 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

  2. Create a statically provisioned PV or a dynamic StorageClass and associate it with the NAS file system.

    • Create a statically provisioned PV.

      1. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose Volumes > Persistent Volumes.

      2. In the upper-right corner of the Persistent Volumes page, click Create.

      3. 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:

        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.

      1. On the Clusters page, find the cluster that you want to manage and click its name. In the left-side pane, choose Volumes > StorageClasses.

      2. In the upper-right corner of the StorageClasses page, click Create.

      3. 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.

        /

  3. Create a persistent volume claim (PVC).

    1. In the left-side navigation pane of the details page, choose Volumes > Persistent Volume Claims.

    2. In the upper-right corner of the Persistent Volume Claims page, click Create.

    3. 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.

      Note

      The 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

  4. Mount the PVC to the application.

    Mount the NAS file system created by using CNFS to the /data path in the container.

    image

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.

  1. Create a CNFS file system by using an existing NAS file system.

    1. 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.

    2. Run the following command to query the NAS file system:

      kubectl get cnfs

      Expected output:

      NAME                  AGE
      cnfs-nas-filesystem   6d
    3. Run the following command to query the details about the NAS file system:

      kubectl get cnfs/cnfs-nas-filesystem -o yaml

      Expected output:

      View expected output

      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":"nas-load-mount-target"},"spec":{"description":"filesystem4","parameters":{"filesystemId":"17f7e4****","server":"17f7e48ece-h****.cn-beijing.nas.aliyuncs.com"},"reclaimPolicy":"Retain","type":"nas"}}
        creationTimestamp: "2021-05-14T08:20:09Z"
        finalizers:
        - protection.alibabacloud.com/cnfs
        generation: 6
        name: cnfs-nas-filesystem
        resourceVersion: "122342382"
        selfLink: /apis/storage.alibabacloud.com/v1beta1/containernetworkfilesystems/nas-load-mount-target
        uid: a9e9650c-68b2-405b-8274-0f5b6063****
      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: Available
  2. 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

  1. Create a CNFS file system.

    1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

    2. On the Clusters page, click the name of the cluster that you want to manage. In the left-side navigation pane, choose Volumes > Container Network File System (CNFS).

    3. On the Container Network File System (CNFS) page, click Create CNFS File System.

    4. 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

  2. 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.