Container Service for Kubernetes (ACK) allows you to create multiple categories of cloud disks in ACK clusters based on your storage requirements and budget in various scenarios. ACK also allows you to change the disk categories of disk volumes to meet changing business requirements. If you create a standard SSD for your application but your application requires a higher IOPS, you can upgrade the category of the disk from standard SSD to Enterprise SSD (ESSD).
Prerequisites
Kubernetes 1.20 or later is used by your cluster and the Container Storage Interface (CSI) plug-in is installed in your cluster.
storage-operator 1.26.1-50a1499-aliyun or later is installed in the cluster.
NoteBy default, storage-operator is installed when you create an ACK cluster. Go to the cluster details page in the ACK console. In the left-side navigation pane of the cluster details page, choose Manage the storage-operator component.
. On the Storage tab, you can check whether storage-operator is installed and view the version of storage-operator. For more information, seeIf your cluster is an ACK dedicated cluster, you must make sure that the worker Resource Access Management (RAM) role and master RAM role of your cluster have the permissions to call the ModifyDiskSpec operation of the Elastic Compute Service (ECS) API. For more information, see Create a custom policy.
NoteIf your cluster is an ACK managed cluster, you do not need to grant the permissions to call the ModifyDiskSpec operation to the cluster.
Usage notes
If the disk category of a disk volume is ESSD AutoPL disk or basic disk, you cannot change the disk category of the volume.
The following table describes the requirements that must be met for disk category changes.
Original disk category
New disk category
Ultra disk
Standard SSD, performance level 0 (PL0) ESSD, PL1 ESSD, PL2 ESSD, PL3 ESSD, and ESSD AutoPL disk.
NoteYou cannot change ultra disks into standard SSDs in Hangzhou Zone D.
Standard SSD
PL0 ESSD, PL1 ESSD, PL2 ESSD, PL3 ESSD, and ESSD AutoPL disk.
PL0 ESSD
PL1 ESSD, PL2 ESSD, PL3 ESSD, and ESSD AutoPL disk.
PL1 ESSD, PL2 ESSD, and PL3 ESSD
PL1 ESSD, PL2 ESSD, PL3 ESSD, and ESSD AutoPL disk.
The ECS instance types to which a cloud disk can be attached depend on the category of the disk. When you change the disk category of a disk volume, make sure that the new disk category is supported by the ECS instance type of the node that hosts the pod to which the volume is mounted. For more information about the matching rules between disk categories and ECS instance types, see Overview of instance families.
Only pay-as-you-go disks can be mounted as volumes. After you change the disk category of a disk volume, the disk is billed based on the billing rules of the new disk category.
For more information, see Limits.
Step 1: Configure storage-operator to enable disk category change
Connect to the cluster and run the following command to modify the storage-operator ConfigMap and enable the disk category change feature: By default, the storage-controller plug-in provided by the storage-operator is used to implement the disk category change feature.
kubectl patch configmap/storage-operator \
-n kube-system \
--type merge \
-p '{"data":{"storage-controller":"{\"imageRep\":\"acs/storage-controller\",\"imageTag\":\"\",\"install\":\"true\",\"template\":\"/acs/templates/storage-controller/install.yaml\",\"type\":\"deployment\"}"}}'
Step 2: Create a custom resource to perform a disk category change
To minimize impacts on your business, we recommend that you perform disk category changes during off-peak hours.
Create a StatefulSet.
If a StatefulSet that has a cloud disk mounted already exists in your cluster, you can skip this step.
Create a file named StatefulSet.yaml and copy the following code block to the file.
The YAML file is used to create a StatefulSet that provisions a pod. The pod has a 40-GiB PL1 ESSD mounted.
apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx-diskspec spec: selector: matchLabels: app: nginx replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 ports: - containerPort: 80 volumeMounts: - name: pvc-disk mountPath: /data volumes: - name: pvc-disk persistentVolumeClaim: claimName: disk-pvc volumeClaimTemplates: - metadata: name: pvc-disk labels: app: nginx spec: accessModes: [ "ReadWriteOnce" ] storageClassName: "alicloud-disk-essd" resources: requests: storage: 40Gi
Create the StatefulSet.
kubectl create -f StatefulSet.yaml
View the pod deployment.
kubectl get pod -l app=nginx
Expected output:
NAME READY STATUS RESTARTS AGE nginx-diskspec-0 1/1 Running 0 4m4s
View information about the persistent volume claim (PVC) used by the StatefulSet and obtain the name of the persistent volume (PV) bound to the PVC.
kubectl get pvc pvc-disk-nginx-diskspec-0
The following output shows that the name of the bound PV is
d-uf6ijdcp3aeoi82w****
, which is displayed in theVOLUME
column.NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE pvc-disk-nginx-diskspec-0 Bound d-uf6ijdcp3aeoi82w**** 40Gi RWO alicloud-disk-essd <unset> 5m6s
View the disk category of the PV.
kubectl get pv d-uf6ijdcp3aeoi82w**** -o=jsonpath='{.metadata.labels}'
cloud_essd.PL1
is returned in the output, which indicates that the PV is used to mount a PL1 ESSD.{"csi.alibabacloud.com/disktype":"cloud_essd.PL1"}
Create a custom resource to perform a disk category change.
Create a file named cr.yaml.
Copy the following YAML template to the file. Replace
pvNames
anddesiredDiskType
with actual values.apiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerStorageOperator metadata: name: default spec: operationType: DISKUPGRADE operationParams: pvNames: "d-uf6ijdcp3aeoi82w****" desiredDiskType: "cloud_auto"
Parameter
Description
operationType
Set the value to DISKUPGRADE.
pvNames
The PV that you want to manage. Separate multiple PVs with commas (,). Example: "disk-1***,disk-2***,disk-3***".
desiredDiskType
The new disk category. Specify the value based on the description in the Usage notes section.
cloud_auto
: ESSD AutoPL disk.cloud_essd.PL0
: PL0 ESSD.cloud_essd.PL1
: PL1 ESSD.cloud_essd.PL2
: PL2 ESSD.cloud_essd.PL3
: PL3 ESSD.cloud_ssd
: standard SSD.
Create the custom resource.
kubectl create -f cr.yaml
Verify that the disk category is changed.
Query the status of the custom resource to check whether the disk category is changed.
kubectl get ContainerStorageOperator default -o yaml
Check the
status
field in the output. Expected output:status: message: [] process: 100% status: SUCCESS
Query the labels of the PV to check whether the disk category is changed to ESSD AutoPL disk.
kubectl get pv d-uf6ijdcp3aeoi82w**** -o=jsonpath='{.metadata.labels}'
Expected output:
{"csi.alibabacloud.com/disktype":"cloud_auto"}