前提条件
已开通文件存储NAS服务。
首次登录文件存储NAS产品详情页时,按照页面引导开通服务。
已创建Kubernetes集群,Kubernetes版本为v1.20及以上,且存储插件选择为CSI。具体操作,请参见创建Kubernetes托管版集群。
CSI-Plugin和CSI-Provisioner组件版本不低于v1.24.11-5221f79-aliyun。关于升级CSI-Plugin和CSI-Provisioner组件的操作,请参见管理CSI组件。
storage-operator组件版本不低于v1.24.105-825188d-aliyun。关于升级storage-operator组件的操作,请参见管理组件。
已通过kubectl工具连接Kubernetes集群。具体操作,请参见获取集群KubeConfig并通过kubectl工具连接集群。
操作步骤
您可以通过以下两种方式使用CNFS管理NAS文件系统。
方式一:使用CNFS管理新建的NAS文件系统
执行以下命令,使用CNFS创建并管理通用容量型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
执行以下命令,查看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内拥有挂载点。关于如何查看挂载点地址,请参见查看挂载点地址。
执行以下命令,将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
执行以下命令,查看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