文档

创建CNFS管理NAS文件系统

容器网络文件系统CNFS(Container Network File System)将阿里云的文件存储抽象为一个K8s对象(CRD)进行独立管理,包括创建、删除、描述、挂载、监控及扩容等运维操作。您可以通过CNFS创建一个新的NAS文件系统或管理已存在的NAS文件系统,以提升NAS文件系统的性能和QoS控制,实现对文件系统层的独立管理。本文介绍如何创建CNFS来管理NAS文件系统。

前提条件

操作步骤

您可以通过以下两种方式使用CNFS管理NAS文件系统。

方式一:使用CNFS管理新建的NAS文件系统

  1. 执行以下命令,使用CNFS创建并管理通用容量型NAS的文件存储。

    说明
    • 通用容量型NAS免费创建,按实际数据量收费。更多信息,请参见计费概述

    • 回收站功能本身不收取任何费用,但是暂存在回收站中的文件将按照删除前的存储类型收取存储费用。更多信息,请参见回收站

    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      # 容量型NAS。
        protocolType: NFS
        encryptType: None
        enableTrashCan: "true"     # 回收站打开。
        trashCanReservedDays: "5"  # 回收站中数据保留5天。
    EOF
  2. 执行以下命令,查看CNFS管理的NAS文件系统。

    kubectl get cnfs cnfs-nas-filesystem -oyaml

    预期输出:

    展开查看预期输出

    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

方式二:使用CNFS管理已有的NAS文件系统

说明

使用CNFS管理已有NAS文件系统,需要确保已有的NAS文件系统已经在ACK所在VPC内拥有挂载点。关于如何查看挂载点地址,请参见查看挂载点地址

  1. 执行以下命令,将NAS文件系统纳入CNFS托管。

    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 # NAS文件系统的挂载点。
    EOF
  2. 执行以下命令,查看CNFS管理的NAS文件系统。

    kubectl get cnfs cnfs-nas-filesystem -oyaml

    预期输出:

    展开查看预期输出

    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

相关文档