Preface
Recently I was learning k8s and used Alibaba Cloud ACK's K8S cluster. When I learned about storage volumes, I found that Alibaba Cloud has three solutions: 1. Cloud disk, 2, NAS, 3, OSS. Let’s explain about cloud disk and How to use NAS in K8S, and there will be time to publish an OSS tutorial later.
ready
- Alibaba Cloud ACK k8s cluster
Overview of k8s storage volumes
storage volume related technology , official document
存储卷PVC:PersistentVolumeClaim
存储卷声明PV:PersistentVolume
存储卷类SC:StorageClass
use
What is statically created storage volume?
The so-called static is to create PV first through the yaml file, then create the PVC, and then specify the PVC through the created Deployment or StatefulSet.
What is dynamically created storage volume?
The so-called dynamic is by creating SC, then creating PVC and specifying SC, the system will automatically create PV, so dynamic creation is more used in actual production.
Below we also focus on how to dynamically create storage volumes.
Storage volume supported by
1, cloud disk
If you want to create a dynamic storage volume, you must first create a StorageClass. The following are the following StorageClasses provided by Alibaba Cloud Disk:
alicloud-disk-efficiency:高效云盘。
alicloud-disk-ssd:SSD云盘。
alicloud-disk-essd:ESSD云盘。
alicloud-disk-available:提供高可用选项,优先创建SSD云盘;如果SSD云盘售尽,则创建高效云盘
alicloud-disk-topology: 使用延迟绑定的方式创建云盘
storage size limit :
最低20Gi
2、NAS
Because the NAS is not the same as the cloud disk, you have to manually activate the service at the Alibaba Cloud console, and you can use it only after activation. Also, the NAS does not have its own SC, and you have to create it through a yaml file.
support protocol:
通用型:NFSv3(Linux)/NFSv4(Linux)/SMB2.1+(Windows)
极速型:NFSv3(Linux)
文件存储 CPFS:POSIX/MPI-IO(Linux)
Cloud Kubernetes CSI supports two types of NAS dynamic storage volume mounting: subpath mode and filesystem mode
subpath类型的NAS动态存储卷
当您的多个Kubernetes应用或者Pod需要挂载相同的NAS存储卷共享数据时,或不同的Pod挂载相同NAS文件系统的不同子目录时, 可以使用subpath类型的NAS动态存储卷方式。
filesystem类型的NAS动态存储卷
当您的Kubernetes应用需要动态创建和删除NAS文件系统和挂载点时, 可以使用filesystem类型。
The following will explain the use of filesystem type to create NAS storage volumes.
storage size limit :
- Unlimited
3、OSS
slightly
Create NAS StorageClass
As mentioned above, the SC that does not come with the NAS needs to be manually created through the yaml file, so now we will create it according to the official document
1. Create a StorageClass of subpath type
alicloud-nas-subpath.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: alicloud-nas-subpath
mountOptions:
- nolock,tcp,noresvport
- vers=3
parameters:
volumeAs: subpath
server: "xxxxxxx.cn-hangzhou.nas.aliyuncs.com:/k8s/"
provisioner: nasplugin.csi.alibabacloud.com
reclaimPolicy: Retain
Execute the following command to create a StorageClass.
kubectl create -f alicloud-nas-subpath.yaml
2. Create a StorageClass of filesystem type
alicloud-nas-fs.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: alicloud-nas-fs
mountOptions:
- nolock,tcp,noresvport
- vers=3
parameters:
volumeAs: filesystem
zoneId: "cn-hangzhou-g"
vpcId: "vpc-xxxxxxxxxxxx"
vSwitchId: "vsw-xxxxxxxxx"
deleteVolume: "false"
provisioner: nasplugin.csi.alibabacloud.com
reclaimPolicy: Retain
Execute the following command to create a StorageClass.
kubectl create -f alicloud-nas-fs.yaml
Note: If you do not fill in the zoneId zone id, an error will be reported
Create cloud disk storage volume
- Step 1: Create PV
- Step 2: Create PVC
- Step 3: Create an application.
- Step 1: Create StorageClass
- Step 2: Create PVC
- Step 3: Create an application
Create NAS storage volume
- Step 1: Create PV
- Step 2: Create PVC
- Step 3: Create an application.
- Step 1: Create StorageClass
- Step 2: Create PVC
- Step 3: Create an application
problem
1. Zone not exist or InvaildZone.NotExist
View pod error report by command
kubectl logs -n kube-system csi-provisioner-56f5c9d65d-2b82t -c external-nas-provisioner
kubectl logs deployment.apps/csi-provisioner -n kube-system
Error message:
RequestId: E83FFC19-9A19-45E4-BC49-BC96810F4C3D
Message: Zone not exist
Warning ProvisioningFailed 10m nasplugin.csi.alibabacloud.com_awbeci-nexus_b88f4540-2802-409e-b178-9f7a37e99191 failed to provision volume with StorageClass "alicloud-nas-fs": rpc error: code = Internal desc = SDK.ServerError
ErrorCode: InvaildZone.NotExist
Recommend: https://error-center.aliyun.com/status/search?Keyword=InvaildZone.NotExist&source=PopGw
Reason: The zoneId was not specified when creating the NAS StorageClass
Solution: corresponding to the area where your NAS is located
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: alicloud-nas-fs
mountOptions:
- nolock,tcp,noresvport
- vers=3
parameters:
volumeAs: filesystem
# 指定zoneId
zoneId: "cn-hangzhou-g"
vpcId: "vpc-xxx"
vSwitchId: "vsw-xxx"
deleteVolume: "false"
provisioner: nasplugin.csi.alibabacloud.com
reclaimPolicy: Retain
to sum up
1. K8s can use cloud disks and NAS storage volumes, but the minimum cloud disk needs 20Gi, so NAS storage volumes can be used for development or testing.
2. Use NAS to open Alibaba Cloud service
3. Dynamically creating storage volumes is more in line with daily work
Quote
Persistent volume
The conceptual relationship between PersistentVolume, PersistentVolumeClaim, and StorageClass in the Kubernetes object
Cloud queries available regions
Cloud Disk Storage Volume 160f6295180b2a
Cloud NAS storage volumes 160f6295180b48
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。