preface

Recently, I learned K8S and used K8S cluster of Aliyun ACK. When I learned the storage volume, I found that Aliyun has three solutions: 1, cloud disk, 2, NAS, 3, OSS. Now let’s explain how to use cloud disk and NAS in K8S.

To prepare

  • Aliyun ACK K8S cluster

Overview of K8S storage volumes

Volume related technology, official documentation

Volume PVC: PersistentVolumeClaim volume declares PV: PersistentVolume volume class SC: StorageClass

Here is a very good blog post that you can take a look at the differences between them when you have time. This post is not about explaining these concepts but about using them

use

  • What is a statically created volume?

    Static is to create a PV from a YAML file, then create a PVC, and then specify a PVC by creating a Deployment or StatefulSet.

  • What is creating a volume dynamically?

    The so-called dynamic is that by creating SC, then creating PVC and specifying SC, the system will automatically create PV, so the actual production uses more dynamic creation.



We will also focus on creating a volume dynamically.

AliCloud supports storage volumes

1.Cloud disk

If you want to create a dynamic storage volume, you must first create StorageClass. Here are the following types of StorageClass provided by ali cloud disk:

Alicloud - Disk-Efficiency: cloud disk Alicloud -disk-ssd: SSD cloud disk Alicloud -disk-essd: essd cloud disk. Alicloud-disk-available: Provides high availability option, preferred to create SSD cloud disk; If SSD cloud disk is sold out, then efficient cloud disk alicloud-disk-topology is created: cloud disk is created using lazy binding

Storage size limit:

Minimum 20 gi

2,NAS

Because NAS is not the same as cloud disk, you need to manually open the service to Ariyun console, and then you can use it. Besides, NAS does not have its own SC, so you need to create it by yourself through YAML file.

Support Agreement:

NFSv3(Linux)/NFSv4(Linux)/SMB2.1+(Windows)

AliCloud Kubernetes CSI supports two types of NAS dynamic volume mount: Subpath and Filesystem

The NAS dynamic volume approach of the Subpath type can be used when multiple Kubernetes applications or PODS need to mount the same NAS volume to share data, or when different PODS mount different subdirectories of the same NAS file system. The filesystem type can be used when your Kubernetes application needs to dynamically create and delete NAS file systems and mount points.

Here’s how to create NAS volumes using the filesystem type.

Storage size limit:

  • unlimited

3, the OSS

slightly

Create the NAS StorageClass

As mentioned above, NAS does not have its own SC which needs to be created manually through YAML file, so now let’s create it according to the official document

Create a StorageClass of type Subpath

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

kubectl create -f alicloud-nas-subpath.yaml

2. Create StorageClass of type Filesystem

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

kubectl create -f alicloud-nas-fs.yaml

Note: If you do not fill in the ZONEID field ID, an error will be reported

Create the cloud disk storage volume

  1. Create a static cloud disk volume

    • Step 1: Create the PV
    • Step 2: Create the PVC
    • Step 3: Create the application.
  2. Create dynamic cloud disk storage volumes

    • Step 1: Create StorageClass
    • Step 2: Create the PVC
    • Step 3: Create the application

Create the NAS storage volume

  1. Create a static cloud disk volume

    • Step 1: Create the PV
    • Step 2: Create the PVC
    • Step 3: Create the application.
  2. Create dynamic cloud disk storage volumes

    • Step 1: Create StorageClass
    • Step 2: Create the PVC
    • Step 3: Create the application

The problem

(1) “Zone not exist” or “invaildzone. NotExist

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



NAS StorageClass was created without specifying ZONEID

Solution:Check the ZONEID corresponding to your NAS area

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-xxx" vSwitchId: "vsw-xxx" deleteVolume: "false" provisioner: nasplugin.csi.alibabacloud.com reclaimPolicy: Retain

conclusion

K8S can use cloud disk and NAS storage volume, but cloud disk minimum 20GI, so normal development or testing can use NAS storage volume 2, use NAS to open AliCloud service 3, dynamic creation of storage volume is more consistent with daily work

reference

The concepts of PersistentVolume, PersistentVolumeClaim, and StorageClass in the Kubernetes object are related to AliCloud query available region AliCloud NAS volume overview AliCloud NAS volume overview