Container Service for Kubernetes (ACK) allows you to create multiple types of cloud disks in Kubernetes clusters based on your storage requirements and budget. ACK also allows you to change the types of cloud disks to meet the changing business requirements. Assume that you have created a standard SSD for your application. If your application requires a higher IOPS, you can upgrade the type of the disk from standard SSD to enhanced SSD (ESSD). This topic describes how to change the type of a cloud disk.
Table of contents
Prerequisites
An ACK cluster that runs Kubernetes 1.20 or later is created. The Container Storage Interface (CSI) plug-in is used as the volume plug-in. For more information, see Create an ACK managed cluster.
The version of storage-operator is v1.26.1-50a1499-aliyun or later. For more information about how to update storage-operator, see Manage system components.
If you use an ACK dedicated cluster, you must grant the following Resource Access Management (RAM) permissions to the worker role used by the cluster. For more information, see Create a custom policy.
NoteIf you use an ACK Pro cluster, you do not need to grant the preceding RAM permissions to the worker role used by the cluster.
Limits
You cannot change the type of ESSD AutoPL disks or ESSD PL-X disks.
For more information about the limits on changing the disk type, see Limits.
Considerations
For more information about the considerations for changing the disk type, see Considerations.
Billing rules
For more information about the billing rules after the disk type is changed, see Billing.
How to change the disk type
Run the following command to modify a ConfigMap in the cluster:
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\"}"}}'
Use the following template to create a custom resource in the cluster:
apiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerStorageOperator metadata: name: default spec: operationType: DISKUPGRADE operationParams: pvNames: "disk-1***,disk-2***,disk-3***" desiredDiskType: "cloud_essd.PL2"
Parameter
Description
operationType
Set the value to DISKUPGRADE.
pvNames
The persistent volumes (PVs) that you want to manage. Separate multiple PVs with commas (,). Example: "disk-1***,disk-2***,disk-3***".
desiredDiskType
The new disk type. Valid values:
cloud_efficiency
cloud_ssd
cloud_essd.PL0
cloud_essd.PL1
cloud_essd.PL2
cloud_essd.PL3
Examples
Create a file named sts-test.yaml and add the following content to the file:
apiVersion: apps/v1 kind: StatefulSet metadata: name: sts-test spec: podManagementPolicy: Parallel selector: matchLabels: app: sts-test replicas: 1 serviceName: sts-test template: metadata: labels: app: sts-test spec: containers: - name: mysql image: mysql:5.7 env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: mysql-pass key: password imagePullPolicy: IfNotPresent volumeMounts: - name: disk mountPath: /data volumeClaimTemplates: - metadata: name: disk spec: accessModes: [ "ReadWriteMany" ] storageClassName: alicloud-disk-topology-alltype resources: requests: storage: 40Gi --- apiVersion: v1 kind: Secret metadata: name: mysql-pass type: Opaque data: username: dGVz**** password: dGVzdDEt****
Run the following command to deploy an application that uses a cloud disk:
kubectl apply -f sts-test.yaml
Run the following command to query the status of the pod that runs the application:
kubectl get pods sts-test-0
Expected output:
NAME READY STATUS RESTARTS sts-test-0 1/1 Running 0
After the pod is in the Running state, run the following command to obtain the PVs that are mounted to the pod:
kubectl get pvc disk-sts-test-0
Expected output:
NAME STATUS VOLUME CAPACITY ACCESS MODES disk-sts-test-0 Bound disk-1aaf007e-36ac-4985-acf0-fc3c85de0e08 500Gi RWX
The output shows that the disk-1aaf007e-36ac-4985-acf0-fc3c85de0e08 PV is mounted to the pod.
Use the following YAML template to create a custom resource. The PV is specified in the template.
apiVersion: storage.alibabacloud.com/v1beta1 kind: ContainerStorageOperator metadata: name: default spec: operationType: DISKUPGRADE operationParams: pvNames: "disk-1aaf007e-36ac-4985-acf0-fc3c85de0e08" desiredDiskType: "cloud_essd.PL2"
If the custom resource is in the
SUCCESS
state, the type of the cloud disk is changed.Run the following command to query the labels of the PV and check whether the PV is updated based on the new disk type:
kubectl get pv disk-1aaf007e-36ac-4985-acf0-fc3c85de0e08 -oyaml
Expected output:
labels: csi.alibabacloud.com/disktype:cloud_essd.PL2 name: disk-1aaf007e-36ac-4985-acf0-fc3c85de0e08 resourceVersion:"89703" uid: 5049a02d-dce3-47a0-9cc6-a4b9c6****
The output shows that the PV is updated and used to mount a cloud disk of the
cloud_essd.PL2
type.