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

Synchronizing Node Pools

Function

This API is used to synchronize the configurations of existing nodes in 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/:projectid/clusters/{cluster_id}/nodepools/{nodepool_id}/operation/upgrade

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

spec

Yes

UpgradeNodePoolSpec object

Parameters in the request for synchronizing a node pool

Table 4 UpgradeNodePoolSpec

Parameter

Mandatory

Type

Description

maxUnavailable

Yes

Integer

Maximum number of nodes to be synchronized in each batch. The value ranges from 1 to 20. It specifies the maximum number of nodes that can be unavailable during node upgrade. Nodes will be unavailable during synchronization by resetting the nodes. Properly configure this parameter to prevent pod scheduling failures caused by too many unavailable nodes in the cluster.

nodeIDs

No

Array of strings

List of node IDs selected in the node pool to be synchronized. For details about how to obtain the IDs, see How to Obtain Parameters in the API URI.

nodePoolID

Yes

String

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

nodeTemplate

No

UpgradeNodePoolSpecNodeTemplate object

Parameters for synchronizing a node pool template

Table 5 UpgradeNodePoolSpecNodeTemplate

Parameter

Mandatory

Type

Description

lifeCycle

Yes

NodeLifecycleConfig object

Customized node lifecycle configurations

login

Yes

Login object

Details:

Node login mode. Either a key pair or password must be used for login.

Constraints:

This parameter cannot be modified when a node pool is being updated.

Table 6 NodeLifecycleConfig

Parameter

Mandatory

Type

Description

preInstall

No

String

Pre-installation script. The characters of both the pre-installation and post-installation scripts are centrally calculated, and the total number of characters after transcoding cannot exceed 10,240.

The input value must be encoded using Base64. The method is as follows:

echo -n "*Content to be encoded*" | base64

postInstall

No

String

Post-installation script. The characters of both the pre-installation and post-installation scripts are centrally calculated, and the total number of characters after transcoding cannot exceed 10,240.

The input value must be encoded using Base64. The method is as follows:

echo -n "*Content to be encoded*" | base64
Table 7 Login

Parameter

Mandatory

Type

Description

sshKey

No

String

Details:

Name of the key pair used for login

Constraints:

None

Options:

N/A

Default value:

N/A

userPassword

No

UserPassword object

Details:

Password used for node login

Constraints:

None

Table 8 UserPassword

Parameter

Mandatory

Type

Description

username

No

String

Details:

Login account. The default value is root.

Constraints:

None

Options:

N/A

Default value:

root

password

Yes

String

Details:

Login password. If a username and password are used when a node is created, this field is shielded in the response body.

Constraints:

The password field must be salted during node creation. For details, see Adding a Salt in the password Field When Creating a Node.

Options:

A password must:

  • Contain 8 to 26 characters.

  • Contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters !@$%^-_=+[{}]:,./?

  • Not contain the username or the username spelled backwards.

Default value:

N/A

Response Parameters

None

Example Requests

  • Synchronize an on-premises node pool.

    {
      "spec" : {
        "maxUnavailable" : 1,
        "nodeIDs" : [ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb" ],
        "nodePoolID" : "cccccccc-cccc-cccc-cccc-cccccccccccc"
      }
    }
  • Synchronize the default node pool.

    {
      "spec" : {
        "maxUnavailable" : 1,
        "nodeIDs" : [ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb" ],
        "nodePoolID" : "DefaultPool",
        "nodeTemplate" : {
          "lifeCycle" : {
            "preInstall" : "ZWNobyAx",
            "postInstall" : "ZWNobyAx"
          },
          "login" : {
            "userPassword" : {
              "password" : "xxxxx",
              "username" : "root"
            }
          }
        }
      }
    }

Example Responses

None

SDK Sample Code

The SDK sample code is as follows.

  • Synchronize an on-premises node pool.

     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 UpgradeNodePoolSolution {
    
        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();
            UpgradeNodePoolRequest request = new UpgradeNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            UpgradeNodePool body = new UpgradeNodePool();
            List<String> listSpecNodeIDs = new ArrayList<>();
            listSpecNodeIDs.add("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
            listSpecNodeIDs.add("bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb");
            NodePoolUpgradeSpec specbody = new NodePoolUpgradeSpec();
            specbody.withNodePoolID("cccccccc-cccc-cccc-cccc-cccccccccccc")
                .withNodeIDs(listSpecNodeIDs)
                .withMaxUnavailable(1);
            body.withSpec(specbody);
            request.withBody(body);
            try {
                UpgradeNodePoolResponse response = client.upgradeNodePool(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());
            }
        }
    }
    
  • Synchronize the default node pool.

     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
    73
    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 UpgradeNodePoolSolution {
    
        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();
            UpgradeNodePoolRequest request = new UpgradeNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            UpgradeNodePool body = new UpgradeNodePool();
            NodeTemplateLifeCycle lifeCycleNodeTemplate = new NodeTemplateLifeCycle();
            lifeCycleNodeTemplate.withPreInstall("ZWNobyAx")
                .withPostInstall("ZWNobyAx");
            NodeTemplateLoginUserPassword userPasswordLogin = new NodeTemplateLoginUserPassword();
            userPasswordLogin.withUsername("root")
                .withPassword("xxxxx");
            NodeTemplateLogin loginNodeTemplate = new NodeTemplateLogin();
            loginNodeTemplate.withUserPassword(userPasswordLogin);
            NodeTemplate nodeTemplateSpec = new NodeTemplate();
            nodeTemplateSpec.withLogin(loginNodeTemplate)
                .withLifeCycle(lifeCycleNodeTemplate);
            List<String> listSpecNodeIDs = new ArrayList<>();
            listSpecNodeIDs.add("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
            listSpecNodeIDs.add("bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb");
            NodePoolUpgradeSpec specbody = new NodePoolUpgradeSpec();
            specbody.withNodePoolID("DefaultPool")
                .withNodeIDs(listSpecNodeIDs)
                .withNodeTemplate(nodeTemplateSpec)
                .withMaxUnavailable(1);
            body.withSpec(specbody);
            request.withBody(body);
            try {
                UpgradeNodePoolResponse response = client.upgradeNodePool(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());
            }
        }
    }
    
  • Synchronize an on-premises node pool.

     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 = UpgradeNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            listNodeIDsSpec = [
                "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
                "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb"
            ]
            specbody = NodePoolUpgradeSpec(
                node_pool_id="cccccccc-cccc-cccc-cccc-cccccccccccc",
                node_i_ds=listNodeIDsSpec,
                max_unavailable=1
            )
            request.body = UpgradeNodePool(
                spec=specbody
            )
            response = client.upgrade_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)
    
  • Synchronize the default node pool.

     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
    # 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 = UpgradeNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            lifeCycleNodeTemplate = NodeTemplateLifeCycle(
                pre_install="ZWNobyAx",
                post_install="ZWNobyAx"
            )
            userPasswordLogin = NodeTemplateLoginUserPassword(
                username="root",
                password="xxxxx"
            )
            loginNodeTemplate = NodeTemplateLogin(
                user_password=userPasswordLogin
            )
            nodeTemplateSpec = NodeTemplate(
                login=loginNodeTemplate,
                life_cycle=lifeCycleNodeTemplate
            )
            listNodeIDsSpec = [
                "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
                "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb"
            ]
            specbody = NodePoolUpgradeSpec(
                node_pool_id="DefaultPool",
                node_i_ds=listNodeIDsSpec,
                node_template=nodeTemplateSpec,
                max_unavailable=1
            )
            request.body = UpgradeNodePool(
                spec=specbody
            )
            response = client.upgrade_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)
    
  • Synchronize an on-premises node pool.

     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
    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.UpgradeNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	var listNodeIDsSpec = []string{
            "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    	    "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb",
        }
    	maxUnavailableSpec:= int32(1)
    	specbody := &model.NodePoolUpgradeSpec{
    		NodePoolID: "cccccccc-cccc-cccc-cccc-cccccccccccc",
    		NodeIDs: &listNodeIDsSpec,
    		MaxUnavailable: &maxUnavailableSpec,
    	}
    	request.Body = &model.UpgradeNodePool{
    		Spec: specbody,
    	}
    	response, err := client.UpgradeNodePool(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Synchronize the default node pool.

     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 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.UpgradeNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	preInstallLifeCycle:= "ZWNobyAx"
    	postInstallLifeCycle:= "ZWNobyAx"
    	lifeCycleNodeTemplate := &model.NodeTemplateLifeCycle{
    		PreInstall: &preInstallLifeCycle,
    		PostInstall: &postInstallLifeCycle,
    	}
    	usernameUserPassword:= "root"
    	passwordUserPassword:= "xxxxx"
    	userPasswordLogin := &model.NodeTemplateLoginUserPassword{
    		Username: &usernameUserPassword,
    		Password: &passwordUserPassword,
    	}
    	loginNodeTemplate := &model.NodeTemplateLogin{
    		UserPassword: userPasswordLogin,
    	}
    	nodeTemplateSpec := &model.NodeTemplate{
    		Login: loginNodeTemplate,
    		LifeCycle: lifeCycleNodeTemplate,
    	}
    	var listNodeIDsSpec = []string{
            "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    	    "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb",
        }
    	maxUnavailableSpec:= int32(1)
    	specbody := &model.NodePoolUpgradeSpec{
    		NodePoolID: "DefaultPool",
    		NodeIDs: &listNodeIDsSpec,
    		NodeTemplate: nodeTemplateSpec,
    		MaxUnavailable: &maxUnavailableSpec,
    	}
    	request.Body = &model.UpgradeNodePool{
    		Spec: specbody,
    	}
    	response, err := client.UpgradeNodePool(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.

  • Synchronize an on-premises node pool.

     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 UpgradeNodePoolSolution {
    
        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();
            UpgradeNodePoolRequest request = new UpgradeNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            UpgradeNodePool body = new UpgradeNodePool();
            List<String> listSpecNodeIDs = new ArrayList<>();
            listSpecNodeIDs.add("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
            listSpecNodeIDs.add("bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb");
            NodePoolUpgradeSpec specbody = new NodePoolUpgradeSpec();
            specbody.withNodePoolID("cccccccc-cccc-cccc-cccc-cccccccccccc")
                .withNodeIDs(listSpecNodeIDs)
                .withMaxUnavailable(1);
            body.withSpec(specbody);
            request.withBody(body);
            try {
                UpgradeNodePoolResponse response = client.upgradeNodePool(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());
            }
        }
    }
    
  • Synchronize the default node pool.

     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
    73
    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 UpgradeNodePoolSolution {
    
        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();
            UpgradeNodePoolRequest request = new UpgradeNodePoolRequest();
            request.withClusterId("{cluster_id}");
            request.withNodepoolId("{nodepool_id}");
            UpgradeNodePool body = new UpgradeNodePool();
            NodeTemplateLifeCycle lifeCycleNodeTemplate = new NodeTemplateLifeCycle();
            lifeCycleNodeTemplate.withPreInstall("ZWNobyAx")
                .withPostInstall("ZWNobyAx");
            NodeTemplateLoginUserPassword userPasswordLogin = new NodeTemplateLoginUserPassword();
            userPasswordLogin.withUsername("root")
                .withPassword("xxxxx");
            NodeTemplateLogin loginNodeTemplate = new NodeTemplateLogin();
            loginNodeTemplate.withUserPassword(userPasswordLogin);
            NodeTemplate nodeTemplateSpec = new NodeTemplate();
            nodeTemplateSpec.withLogin(loginNodeTemplate)
                .withLifeCycle(lifeCycleNodeTemplate);
            List<String> listSpecNodeIDs = new ArrayList<>();
            listSpecNodeIDs.add("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
            listSpecNodeIDs.add("bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb");
            NodePoolUpgradeSpec specbody = new NodePoolUpgradeSpec();
            specbody.withNodePoolID("DefaultPool")
                .withNodeIDs(listSpecNodeIDs)
                .withNodeTemplate(nodeTemplateSpec)
                .withMaxUnavailable(1);
            body.withSpec(specbody);
            request.withBody(body);
            try {
                UpgradeNodePoolResponse response = client.upgradeNodePool(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());
            }
        }
    }
    
  • Synchronize an on-premises node pool.

     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 = UpgradeNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            listNodeIDsSpec = [
                "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
                "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb"
            ]
            specbody = NodePoolUpgradeSpec(
                node_pool_id="cccccccc-cccc-cccc-cccc-cccccccccccc",
                node_i_ds=listNodeIDsSpec,
                max_unavailable=1
            )
            request.body = UpgradeNodePool(
                spec=specbody
            )
            response = client.upgrade_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)
    
  • Synchronize the default node pool.

     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
    # 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 = UpgradeNodePoolRequest()
            request.cluster_id = "{cluster_id}"
            request.nodepool_id = "{nodepool_id}"
            lifeCycleNodeTemplate = NodeTemplateLifeCycle(
                pre_install="ZWNobyAx",
                post_install="ZWNobyAx"
            )
            userPasswordLogin = NodeTemplateLoginUserPassword(
                username="root",
                password="xxxxx"
            )
            loginNodeTemplate = NodeTemplateLogin(
                user_password=userPasswordLogin
            )
            nodeTemplateSpec = NodeTemplate(
                login=loginNodeTemplate,
                life_cycle=lifeCycleNodeTemplate
            )
            listNodeIDsSpec = [
                "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
                "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb"
            ]
            specbody = NodePoolUpgradeSpec(
                node_pool_id="DefaultPool",
                node_i_ds=listNodeIDsSpec,
                node_template=nodeTemplateSpec,
                max_unavailable=1
            )
            request.body = UpgradeNodePool(
                spec=specbody
            )
            response = client.upgrade_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)
    
  • Synchronize an on-premises node pool.

     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
    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.UpgradeNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	var listNodeIDsSpec = []string{
            "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    	    "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb",
        }
    	maxUnavailableSpec:= int32(1)
    	specbody := &model.NodePoolUpgradeSpec{
    		NodePoolID: "cccccccc-cccc-cccc-cccc-cccccccccccc",
    		NodeIDs: &listNodeIDsSpec,
    		MaxUnavailable: &maxUnavailableSpec,
    	}
    	request.Body = &model.UpgradeNodePool{
    		Spec: specbody,
    	}
    	response, err := client.UpgradeNodePool(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Synchronize the default node pool.

     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 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.UpgradeNodePoolRequest{}
    	request.ClusterId = "{cluster_id}"
    	request.NodepoolId = "{nodepool_id}"
    	preInstallLifeCycle:= "ZWNobyAx"
    	postInstallLifeCycle:= "ZWNobyAx"
    	lifeCycleNodeTemplate := &model.NodeTemplateLifeCycle{
    		PreInstall: &preInstallLifeCycle,
    		PostInstall: &postInstallLifeCycle,
    	}
    	usernameUserPassword:= "root"
    	passwordUserPassword:= "xxxxx"
    	userPasswordLogin := &model.NodeTemplateLoginUserPassword{
    		Username: &usernameUserPassword,
    		Password: &passwordUserPassword,
    	}
    	loginNodeTemplate := &model.NodeTemplateLogin{
    		UserPassword: userPasswordLogin,
    	}
    	nodeTemplateSpec := &model.NodeTemplate{
    		Login: loginNodeTemplate,
    		LifeCycle: lifeCycleNodeTemplate,
    	}
    	var listNodeIDsSpec = []string{
            "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    	    "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb",
        }
    	maxUnavailableSpec:= int32(1)
    	specbody := &model.NodePoolUpgradeSpec{
    		NodePoolID: "DefaultPool",
    		NodeIDs: &listNodeIDsSpec,
    		NodeTemplate: nodeTemplateSpec,
    		MaxUnavailable: &maxUnavailableSpec,
    	}
    	request.Body = &model.UpgradeNodePool{
    		Spec: specbody,
    	}
    	response, err := client.UpgradeNodePool(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

200

The node pool synchronization has been accepted.

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