Updated on 2025-11-05 GMT+08:00

Modifying a Cluster Flavor (Discarded)

Function

This API is used to modify the flavor of a cluster.

  • The URL for cluster management is in the format of https://Endpoint/uri, in which uri indicates the resource path, that is, the path for API access.

  • For details about constraints, see Changing a Cluster Scale.

Calling Method

For details, see Calling APIs.

URI

POST /api/v2/projects/{project_id}/clusters/{cluster_id}/resize

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details about how to obtain the project ID, see How to Obtain Parameters in the API URI.

Constraints

N/A

Range

The project ID of the account

Default Value

N/A

cluster_id

Yes

String

Definition

Cluster ID. For details about how to obtain the cluster ID, see How to Obtain Parameters in the API URI.

Constraints

N/A

Range

Cluster ID

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Definition

The request body type or format

Constraints

GET requests are not validated.

Range

  • application/json

  • application/json;charset=utf-8

  • application/x-pem-file

  • multipart/form-data (used when the FormData parameter is present)

Default Value

N/A

X-Auth-Token

Yes

String

Definition

Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details about how to obtain a token, see Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

flavorResize

Yes

String

Definition

The target flavor to be changed. You can only adjust the maximum number of worker nodes in a cluster. The number of control plane nodes is fixed and cannot be altered, and the cluster flavor cannot be downgraded. Suppose the original cluster flavor is cce.s2.medium. In that case, you can only upgrade it to cce.s2.large or higher, but you cannot downgrade it to cce.s2.small or cce.s1.medium.

Constraints

A cluster that uses a VPC network should have 1000 or fewer nodes. The cluster scale is limited by the VPC route table. If you upgrade the cluster flavor to cce.s2.xlarge, the actual number of nodes may be less than the target number.

Range

  • cce.s1.small: a small-scale CCE cluster with one control plane node and a maximum of 50 worker nodes

  • cce.s1.medium: a medium-scale CCE cluster with one control plane node and a maximum of 200 worker nodes

  • cce.s2.small: a small-scale CCE cluster with three control plane nodes and a maximum of 50 worker nodes

  • cce.s2.medium: a medium-scale CCE cluster with three control plane nodes and a maximum of 200 worker nodes

  • cce.s2.large: a large-scale CCE cluster with three control plane nodes and a maximum of 1,000 worker nodes

  • cce.s2.xlarge: an ultra-large-scale CCE cluster with three control plane nodes and a maximum of 2,000 worker nodes

Default Value

N/A

NOTE:

The fields in the parameters are described as follows:

  • s1: specifies a cluster with one control plane node. If the control plane node is faulty, the cluster will become unavailable, but running workloads in the cluster are not affected.

  • s2: specifies a cluster with three control plane nodes. This is an HA cluster. If one of the control plane nodes is faulty, the cluster is still available.

  • dec: specifies a DeC CCE cluster. For example, cce.dec.s1.small specifies a small-scale, DeC CCE cluster with one control plane node and a maximum of 50 worker nodes.

  • small: specifies that a cluster can manage a maximum of 50 worker nodes.

  • medium: specifies that a cluster can manage a maximum of 200 worker nodes.

  • large: specifies that a cluster can manage a maximum of 1000 worker nodes.

  • xlarge: specifies that a cluster can manage a maximum of 2000 worker nodes.

skippedTasks

No

Array of strings

Definition

Whether to skip some tasks during a cluster flavor change

Constraints

N/A

Range

  • IngressChecker: The check of configuration consistency between the ingress and ELB is skipped during the cluster flavor change.

NOTE:

Default Value

An unavailable cluster includes IngressChecker by default.

extendParam

No

extendParam object

Definition

Extended field for changing cluster flavors

Constraints

N/A

Table 4 extendParam

Parameter

Mandatory

Type

Description

decMasterFlavor

No

String

Definition

The flavors of the control plane nodes can be specified for a DeC CCE cluster.

Constraints

N/A

Range

N/A

Default Value

N/A

isAutoPay

No

String

Definition

Whether to enable auto payment

Constraints

N/A

Range

  • true: Auto payment is enabled.

  • false: Auto payment is not enabled.

NOTE:

This parameter is valid only for clusters billed on a yearly/monthly basis. If this parameter is not set, auto payment is disabled by default.

Default Value

N/A

Response Parameters

Status code: 201

Table 5 Response body parameters

Parameter

Type

Description

jobID

String

Definition

Job ID

Constraints

N/A

Range

N/A

Default Value

N/A

orderID

String

Definition

ID of the order for modifying the flavor of a yearly/monthly cluster

Constraints

v2 APIs do not allow you to change the flavor of a yearly/monthly cluster.

Range

N/A

Default Value

N/A

Example Requests

Modify the flavor of a pay-per-use cluster.

POST /api/v2/projects/{project_id}/clusters/{cluster_id}/resize

{
  "flavorResize" : "cce.s1.medium"
}

Example Responses

Status code: 201

The job for modifying the flavor of the pay-per-use cluster was delivered.

{
  "jobID" : "13b8d958-8fcf-11ed-aef3-0255ac1001bd"
}

SDK Sample Code

The SDK sample code is as follows.

Modify the flavor of a pay-per-use cluster.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cce.v3.region.CceRegion;
import com.huaweicloud.sdk.cce.v3.*;
import com.huaweicloud.sdk.cce.v3.model.*;


public class ResizeClusterSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        CceClient client = CceClient.newBuilder()
                .withCredential(auth)
                .withRegion(CceRegion.valueOf("<YOUR REGION>"))
                .build();
        ResizeClusterRequest request = new ResizeClusterRequest();
        request.withClusterId("{cluster_id}");
        ResizeClusterRequestBody body = new ResizeClusterRequestBody();
        body.withFlavorResize("cce.s1.medium");
        request.withBody(body);
        try {
            ResizeClusterResponse response = client.resizeCluster(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Modify the flavor of a pay-per-use cluster.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcce.v3.region.cce_region import CceRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcce.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = CceClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CceRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ResizeClusterRequest()
        request.cluster_id = "{cluster_id}"
        request.body = ResizeClusterRequestBody(
            flavor_resize="cce.s1.medium"
        )
        response = client.resize_cluster(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Modify the flavor of a pay-per-use cluster.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := cce.NewCceClient(
        cce.CceClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ResizeClusterRequest{}
	request.ClusterId = "{cluster_id}"
	request.Body = &model.ResizeClusterRequestBody{
		FlavorResize: "cce.s1.medium",
	}
	response, err := client.ResizeCluster(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in the API Explorer.

Status Codes

Status Code

Description

201

The job for modifying the flavor of the pay-per-use cluster was delivered.

Error Codes

See Error Codes.