All Products
Search
Document Center

Container Service for Kubernetes:Change the type of a cloud disk

Last Updated:Jun 19, 2024

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 enterprise 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 the storage-operator component is v1.26.1-50a1499-aliyun or later. For more information about how to update storage-operator, see Manage components.

  • If you use an ACK dedicated cluster, you need to grant the following permissions to the worker role and master role. For more information, see Create custom policies.

    View content of the permission policy attached to the worker role and master role

    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ecs:CreateSnapshot",
                    "ecs:DescribeSnapshot",
                    "ecs:DeleteSnapshot",
                    "ecs:ModifyDiskSpec",
                    "ecs:DescribeTaskAttribute"
                ],
                "Resource": "*"
            }
        ]
    }
    Note

    If you use an ACK Pro cluster, you do not need to grant the preceding RAM permissions.

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 for changing the disk type, see Billing.

How to change the disk type

  1. Run the following command to modify the ConfigMap:

    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\"}"}}'
  2. Create a ContainerStorageOperator CustomResource (CR) based on the following content:

    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

  1. 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****    
  2. Run the following command to deploy an application that uses cloud disks:

    kubectl apply -f sts-test.yaml
  3. Run the following command to query the status of the pods:

    kubectl get pods sts-test-0

    Expected output:

    NAME          READY  STATUS    RESTARTS
    sts-test-0    1/1    Running   0
  4. Wait until the pod enters the Running state and run the following command to query the name of the PV 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.

  5. Pass the PV name as a parameter to the CR that you need to create and create the CR.

    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"
  6. Wait until the CR enters the SUCCESS state. This indicates that the disk type is changed.

    CR

  7. Run the following command to query the labels of the PV to confirm that the disk type is changed.

    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 indicates that the disk type is changed to cloud_essd.PL2.