Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Scaling a Node Pool

Function

This API is used to scale in or out a node pool.

NOTE:

The URL for cluster management is in the format of https://Endpoint/uri, where uri specifies the resource path for API access.

Calling Method

For details, see Calling APIs.

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodepools/{nodepool_id}/operation/scale

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Details:

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

Constraints:

None

Options:

Project IDs of the account

Default value:

N/A

cluster_id

Yes

String

Details:

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

Constraints:

None

Options:

Cluster IDs

Default value:

N/A

nodepool_id

Yes

String

Details:

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

Constraints:

None

Options:

Cluster IDs

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Details:

The request body type or format

Constraints:

The GET method is not verified.

Options:

  • 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

Details:

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, see Obtaining a User Token.

Constraints:

None

Options:

N/A

Default value:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

kind

Yes

String

Details:

API type

Constraints:

None

Options:

The value is fixed at NodePool.

Default value:

N/A

apiVersion

Yes

String

Details:

API version

Constraints:

None

Options:

The value is fixed at v3.

Default value:

N/A

spec

Yes

ScaleNodePoolSpec object

Details:

Parameters in the request for scaling a node pool

Constraints:

None

Table 4 ScaleNodePoolSpec

Parameter

Mandatory

Type

Description

desiredNodeCount

Yes

Integer

Details:

Desired number of nodes in a node pool

Constraints:

This parameter is mandatory. If it is omitted, the default value 0 is used. This will result in the deletion of all nodes in the node pool scaling group.

Options:

0 or a positive integer

Default value:

0

scaleGroups

Yes

Array of strings

Details:

Name of the scaling group in a node pool to be scaled

Constraints:

Only one scaling group name can be specified. If the default scaling group is required, set the parameter to default.

Options:

N/A

Default value:

N/A

options

No

ScaleNodePoolOptions object

Details:

Configurations of node pool scaling options

Constraints:

None

Table 5 ScaleNodePoolOptions

Parameter

Mandatory

Type

Description

scalableChecking

No

String

Details:

Policy for checking the scale-out

Constraints:

None

Options:

  • instant: When a scale-out request is delivered, the system synchronously checks whether the underlying resources are sold out.
  • async: When a scale-out request is delivered, the system asynchronously checks whether the underlying resources are sold out.

    Default value:

    instant

billingConfigOverride

No

ScaleUpBillingConfigOverride object

Details:

The default billing mode of a node pool will be overwritten when the node pool is scaled out. If the scale-out of yearly/monthly nodes is needed in a new node pool, this parameter is required. In other scenarios, you are not advised to use this parameter.

Constraints:

Only clusters of v1.21.11-r0, v1.23.9-r0, v1.25.4-r0, and later versions support the scale-out of yearly/monthly nodes in pay-per-use node pools.

Table 6 ScaleUpBillingConfigOverride

Parameter

Mandatory

Type

Description

billingMode

No

Integer

Details:

Billing mode of a node

Constraints:

This parameter is optional. If it is not specified, the default billing mode of the node pool where the node is in is used.

Options:

  • 0: pay-per-use
  • 1: yearly/monthly

    Default value:

    N/A

extendParam

No

ScaleUpExtendParam object

Details:

Parameters for configuring the yearly/monthly billing mode

Constraints:

  • This parameter is not considered in the pay-per-use billing mode.
  • This parameter is mandatory for the yearly/monthly billing mode.
Table 7 ScaleUpExtendParam

Parameter

Mandatory

Type

Description

periodNum

Yes

Integer

Details:

Yearly/Monthly duration

Constraints:

None

Options:

  • If periodType is month, the value ranges from 1 to 9.
  • If periodType is year, the value ranges from 1 to 3.

    Default value:

    N/A

periodType

Yes

String

Details:

Yearly/Monthly type

Constraints:

None

Options:

  • year
  • month

    Default value:

    N/A

isAutoRenew

No

Boolean

Details:

Whether to enable auto renewal

Constraints:

It is valid when billingMode is set to 1. If it is left blank, auto renewal is not enabled by default.

Options:

  • true: Auto renewal is enabled.
  • false: Auto renewal is not enabled.

    Default value:

    N/A

isAutoPay

No

Boolean

Details:

Whether an order is automatically or manually paid

Constraints:

This field is valid when billingMode is set to 1 or 2 (discarded). If not specified when billingMode is set to 1, auto payment is not enabled.

Options:

  • true: Auto payment is enabled.
  • false: Auto payment is not enabled.

    Default value:

    N/A

Response Parameters

None

Example Requests

  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
    {
      "kind" : "NodePool",
      "apiVersion" : "v3",
      "spec" : {
        "desiredNodeCount" : 1,
        "scaleGroups" : [ "default" ]
      }
    }
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
    {
      "kind" : "NodePool",
      "apiVersion" : "v3",
      "spec" : {
        "desiredNodeCount" : 1,
        "scaleGroups" : [ "default" ],
        "options" : {
          "billingConfigOverride" : {
            "billingMode" : 1,
            "extendParam" : {
              "periodNum" : 1,
              "periodType" : "month",
              "isAutoRenew" : false,
              "isAutoPay" : false
            }
          }
        }
      }
    }

Example Responses

None

SDK Sample Code

The SDK sample code is as follows.

  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class ScaleNodePoolSolution {
    
        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();
            ScaleNodePoolRequest request = new ScaleNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            ScaleNodePoolRequestBody body = new ScaleNodePoolRequestBody();
            List<String> listSpecScaleGroups = new ArrayList<>();
            listSpecScaleGroups.add("default");
            ScaleNodePoolSpec specbody = new ScaleNodePoolSpec();
            specbody.withDesiredNodeCount(1)
                .withScaleGroups(listSpecScaleGroups);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("NodePool");
            request.withBody(body);
            try {
                ScaleNodePoolResponse response = client.scaleNodePool(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());
            }
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class ScaleNodePoolSolution {
    
        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();
            ScaleNodePoolRequest request = new ScaleNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            ScaleNodePoolRequestBody body = new ScaleNodePoolRequestBody();
            ScaleUpExtendParam extendParamBillingConfigOverride = new ScaleUpExtendParam();
            extendParamBillingConfigOverride.withPeriodNum(1)
                .withPeriodType("month")
                .withIsAutoRenew(false)
                .withIsAutoPay(false);
            ScaleUpBillingConfigOverride billingConfigOverrideOptions = new ScaleUpBillingConfigOverride();
            billingConfigOverrideOptions.withBillingMode(1)
                .withExtendParam(extendParamBillingConfigOverride);
            ScaleNodePoolOptions optionsSpec = new ScaleNodePoolOptions();
            optionsSpec.withBillingConfigOverride(billingConfigOverrideOptions);
            List<String> listSpecScaleGroups = new ArrayList<>();
            listSpecScaleGroups.add("default");
            ScaleNodePoolSpec specbody = new ScaleNodePoolSpec();
            specbody.withDesiredNodeCount(1)
                .withScaleGroups(listSpecScaleGroups)
                .withOptions(optionsSpec);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("NodePool");
            request.withBody(body);
            try {
                ScaleNodePoolResponse response = client.scaleNodePool(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());
            }
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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
    # 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 = ScaleNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            listScaleGroupsSpec = [
                "default"
            ]
            specbody = ScaleNodePoolSpec(
                desired_node_count=1,
                scale_groups=listScaleGroupsSpec
            )
            request.body = ScaleNodePoolRequestBody(
                spec=specbody,
                api_version="v3",
                kind="NodePool"
            )
            response = client.scale_node_pool(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    # 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 = ScaleNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            extendParamBillingConfigOverride = ScaleUpExtendParam(
                period_num=1,
                period_type="month",
                is_auto_renew=False,
                is_auto_pay=False
            )
            billingConfigOverrideOptions = ScaleUpBillingConfigOverride(
                billing_mode=1,
                extend_param=extendParamBillingConfigOverride
            )
            optionsSpec = ScaleNodePoolOptions(
                billing_config_override=billingConfigOverrideOptions
            )
            listScaleGroupsSpec = [
                "default"
            ]
            specbody = ScaleNodePoolSpec(
                desired_node_count=1,
                scale_groups=listScaleGroupsSpec,
                options=optionsSpec
            )
            request.body = ScaleNodePoolRequestBody(
                spec=specbody,
                api_version="v3",
                kind="NodePool"
            )
            response = client.scale_node_pool(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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 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.ScaleNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	var listScaleGroupsSpec = []string{
            "default",
        }
    	specbody := &model.ScaleNodePoolSpec{
    		DesiredNodeCount: int32(1),
    		ScaleGroups: listScaleGroupsSpec,
    	}
    	request.Body = &model.ScaleNodePoolRequestBody{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "NodePool",
    	}
    	response, err := client.ScaleNodePool(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    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.ScaleNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	isAutoRenewExtendParam:= false
    	isAutoPayExtendParam:= false
    	extendParamBillingConfigOverride := &model.ScaleUpExtendParam{
    		PeriodNum: int32(1),
    		PeriodType: "month",
    		IsAutoRenew: &isAutoRenewExtendParam,
    		IsAutoPay: &isAutoPayExtendParam,
    	}
    	billingConfigOverrideOptions := &model.ScaleUpBillingConfigOverride{
    		BillingMode: int32(1),
    		ExtendParam: extendParamBillingConfigOverride,
    	}
    	optionsSpec := &model.ScaleNodePoolOptions{
    		BillingConfigOverride: billingConfigOverrideOptions,
    	}
    	var listScaleGroupsSpec = []string{
            "default",
        }
    	specbody := &model.ScaleNodePoolSpec{
    		DesiredNodeCount: int32(1),
    		ScaleGroups: listScaleGroupsSpec,
    		Options: optionsSpec,
    	}
    	request.Body = &model.ScaleNodePoolRequestBody{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "NodePool",
    	}
    	response, err := client.ScaleNodePool(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 API Explorer. SDK sample code can be automatically generated.

  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class ScaleNodePoolSolution {
    
        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();
            ScaleNodePoolRequest request = new ScaleNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            ScaleNodePoolRequestBody body = new ScaleNodePoolRequestBody();
            List<String> listSpecScaleGroups = new ArrayList<>();
            listSpecScaleGroups.add("default");
            ScaleNodePoolSpec specbody = new ScaleNodePoolSpec();
            specbody.withDesiredNodeCount(1)
                .withScaleGroups(listSpecScaleGroups);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("NodePool");
            request.withBody(body);
            try {
                ScaleNodePoolResponse response = client.scaleNodePool(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());
            }
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    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.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class ScaleNodePoolSolution {
    
        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();
            ScaleNodePoolRequest request = new ScaleNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            ScaleNodePoolRequestBody body = new ScaleNodePoolRequestBody();
            ScaleUpExtendParam extendParamBillingConfigOverride = new ScaleUpExtendParam();
            extendParamBillingConfigOverride.withPeriodNum(1)
                .withPeriodType("month")
                .withIsAutoRenew(false)
                .withIsAutoPay(false);
            ScaleUpBillingConfigOverride billingConfigOverrideOptions = new ScaleUpBillingConfigOverride();
            billingConfigOverrideOptions.withBillingMode(1)
                .withExtendParam(extendParamBillingConfigOverride);
            ScaleNodePoolOptions optionsSpec = new ScaleNodePoolOptions();
            optionsSpec.withBillingConfigOverride(billingConfigOverrideOptions);
            List<String> listSpecScaleGroups = new ArrayList<>();
            listSpecScaleGroups.add("default");
            ScaleNodePoolSpec specbody = new ScaleNodePoolSpec();
            specbody.withDesiredNodeCount(1)
                .withScaleGroups(listSpecScaleGroups)
                .withOptions(optionsSpec);
            body.withSpec(specbody);
            body.withApiVersion("v3");
            body.withKind("NodePool");
            request.withBody(body);
            try {
                ScaleNodePoolResponse response = client.scaleNodePool(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());
            }
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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
    # 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 = ScaleNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            listScaleGroupsSpec = [
                "default"
            ]
            specbody = ScaleNodePoolSpec(
                desired_node_count=1,
                scale_groups=listScaleGroupsSpec
            )
            request.body = ScaleNodePoolRequestBody(
                spec=specbody,
                api_version="v3",
                kind="NodePool"
            )
            response = client.scale_node_pool(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    # 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 = ScaleNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            extendParamBillingConfigOverride = ScaleUpExtendParam(
                period_num=1,
                period_type="month",
                is_auto_renew=False,
                is_auto_pay=False
            )
            billingConfigOverrideOptions = ScaleUpBillingConfigOverride(
                billing_mode=1,
                extend_param=extendParamBillingConfigOverride
            )
            optionsSpec = ScaleNodePoolOptions(
                billing_config_override=billingConfigOverrideOptions
            )
            listScaleGroupsSpec = [
                "default"
            ]
            specbody = ScaleNodePoolSpec(
                desired_node_count=1,
                scale_groups=listScaleGroupsSpec,
                options=optionsSpec
            )
            request.body = ScaleNodePoolRequestBody(
                spec=specbody,
                api_version="v3",
                kind="NodePool"
            )
            response = client.scale_node_pool(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Scale out nodes in the default scaling group of a node pool (pay-per-use).
     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 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.ScaleNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	var listScaleGroupsSpec = []string{
            "default",
        }
    	specbody := &model.ScaleNodePoolSpec{
    		DesiredNodeCount: int32(1),
    		ScaleGroups: listScaleGroupsSpec,
    	}
    	request.Body = &model.ScaleNodePoolRequestBody{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "NodePool",
    	}
    	response, err := client.ScaleNodePool(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Scale out nodes in the default scaling group of a node pool (yearly/monthly).
     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    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.ScaleNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	isAutoRenewExtendParam:= false
    	isAutoPayExtendParam:= false
    	extendParamBillingConfigOverride := &model.ScaleUpExtendParam{
    		PeriodNum: int32(1),
    		PeriodType: "month",
    		IsAutoRenew: &isAutoRenewExtendParam,
    		IsAutoPay: &isAutoPayExtendParam,
    	}
    	billingConfigOverrideOptions := &model.ScaleUpBillingConfigOverride{
    		BillingMode: int32(1),
    		ExtendParam: extendParamBillingConfigOverride,
    	}
    	optionsSpec := &model.ScaleNodePoolOptions{
    		BillingConfigOverride: billingConfigOverrideOptions,
    	}
    	var listScaleGroupsSpec = []string{
            "default",
        }
    	specbody := &model.ScaleNodePoolSpec{
    		DesiredNodeCount: int32(1),
    		ScaleGroups: listScaleGroupsSpec,
    		Options: optionsSpec,
    	}
    	request.Body = &model.ScaleNodePoolRequestBody{
    		Spec: specbody,
    		ApiVersion: "v3",
    		Kind: "NodePool",
    	}
    	response, err := client.ScaleNodePool(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 API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

202

The node pool scaling is accepted. Nodes in the node pool will be added or deleted based on the expected number of nodes in the node pool after scaling.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback