容器網路檔案系統CNFS(Container Network File System)將阿里雲的檔案儲存體抽象為一個K8s對象(CRD)進行獨立管理,包括建立、刪除、描述、掛載、監控及擴容等營運操作。您可以通過CNFS建立一個新的NAS檔案系統或管理已存在的NAS檔案系統,以提升NAS檔案系統的效能和QoS控制,實現對檔案系統層的獨立管理。本文介紹如何建立CNFS來管理NAS檔案系統。
操作步驟
您可以通過以下兩種方式使用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