Synchronizing Node Configurations in a Node Pool
Function
This API is used to synchronize the configurations of existing nodes in a node pool.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
cce:nodepool:upgradeNodepool
Write
cluster *
-
cce:nodepool:update
-
-
g:EnterpriseProjectId
URI
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodepools/{nodepool_id}/operation/upgrade
| 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
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | Yes | String | Definition: Type (or format) of the request body. The default value is application/json. Other values of this field will be provided for specific APIs, if any. Constraints: GET requests are not validated. Range: N/A 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 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| kind | No | String | Definition: API type Constraints: The value cannot be changed. Range: N/A Default Value: NodePool |
| apiVersion | No | String | Definition: API version Constraints: The value cannot be changed. Range: N/A Default Value: v3 |
| metadata | No | NodePoolMetadata object | Metadata of a node pool |
| spec | Yes | UpgradeNodePoolSpec object | Definition Parameters in the request for synchronizing nodes in a node pool Constraints N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition Node pool name Constraints You are not allowed to create node pools named DefaultPool. Range Enter 1 to 63 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. Default Value N/A |
| uid | No | String | Details: UID of a node pool Constraints: The value is automatically generated after the object is created. A user-defined value will not take effect. Options: N/A Default value: N/A |
| annotations | No | Map<String,String> | Details: Annotations of a node pool in key-value pairs Constraints: This parameter is used only for query and cannot be input through a request. Entered data of this parameter is invalid. |
| updateTimestamp | No | String | Details: Time when a node pool was updated Constraints: The value is automatically recorded when a node pool is updated and cannot be specified. Options: N/A Default value: N/A |
| creationTimestamp | No | String | Details: Time when a node pool was created Constraints: The value is automatically recorded when a node pool is created and cannot be specified. Options: N/A Default value: N/A |
| resourceVersion | No | Integer | Definition Timestamp of the last update time of a node pool Constraints The value is automatically recorded when a node pool is created and cannot be specified. Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| maxUnavailable | Yes | Integer | Definition The maximum number of nodes to be synchronized at a time. It also specifies the maximum number of unavailable nodes during node upgrades. When a node is reset for synchronization, the node is unavailable. Set this parameter to a proper value to prevent pod scheduling failures caused by a large number of unavailable nodes in the cluster. Constraints N/A Range 1 to 20 Default Value N/A |
| nodeIDs | No | Array of strings | Definition 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. Constraints N/A Range N/A Default Value N/A |
| nodePoolID | Yes | String | Definition Node pool ID. For details about how to obtain the ID, see How to Obtain Parameters in the API URI. Constraints N/A Range N/A Default Value N/A |
| nodeTemplate | No | Definition Template parameters for synchronizing a node pool Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| lifeCycle | Yes | NodeLifecycleConfig object | Definition Customized node lifecycle settings Constraints N/A |
| login | Yes | Login object | Details: Node login mode. Either a key pair or password must be used for login. Constraints: None |
| volumeConfig | No | VolumeConfig object | Definition: Disk configuration in the node pool synchronization scenario Constraints: N/A |
| 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 | Definition: Password used for node login Constraints: N/A Range: N/A Default Value: N/A |
| removeUserPassword | No | Boolean | Definition Whether to remove the password login setting of a node pool during the node pool update Constraints This parameter is supported only during node pool updates. If it is set to true, no user password can be specified. Range N/A Default Value false |
| removeSSHKey | No | Boolean | Definition Whether to remove the key pair login setting of a node pool during the node pool update Constraints This parameter is supported only during node pool updates. If it is set to true, no SSH key can be specified. Range N/A Default Value false |
| 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:
Default value: N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| jobid | String | Definition: Specifies the job ID returned after the job is successfully delivered. You can use this ID to query the job execution status. Range: N/A |
Example Requests
-
Synchronize the node configurations in 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 node configurations in 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
Status code: 200
The job information is obtained.
{
"jobid" : "7b9a1695-ab29-11ef-a522-0255ac101231"
} SDK Sample Code
The SDK sample code is as follows.
-
Synchronize the node configurations in 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.withMaxUnavailable(1) .withNodeIDs(listSpecNodeIDs) .withNodePoolID("cccccccc-cccc-cccc-cccc-cccccccccccc"); 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 node configurations in 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
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(); UserPassword userPasswordLogin = new UserPassword(); userPasswordLogin.withUsername("root") .withPassword("xxxxx"); Login loginNodeTemplate = new Login(); loginNodeTemplate.withUserPassword(userPasswordLogin); NodeTemplate nodeTemplateSpec = new NodeTemplate(); nodeTemplateSpec.withLogin(loginNodeTemplate); List<String> listSpecNodeIDs = new ArrayList<>(); listSpecNodeIDs.add("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"); listSpecNodeIDs.add("bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb"); NodePoolUpgradeSpec specbody = new NodePoolUpgradeSpec(); specbody.withMaxUnavailable(1) .withNodeIDs(listSpecNodeIDs) .withNodePoolID("DefaultPool") .withNodeTemplate(nodeTemplateSpec); 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 node configurations in 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( max_unavailable=1, node_i_ds=listNodeIDsSpec, node_pool_id="cccccccc-cccc-cccc-cccc-cccccccccccc" ) 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 node configurations in 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
# 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}" userPasswordLogin = UserPassword( username="root", password="xxxxx" ) loginNodeTemplate = Login( user_password=userPasswordLogin ) nodeTemplateSpec = NodeTemplate( login=loginNodeTemplate ) listNodeIDsSpec = [ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb" ] specbody = NodePoolUpgradeSpec( max_unavailable=1, node_i_ds=listNodeIDsSpec, node_pool_id="DefaultPool", node_template=nodeTemplateSpec ) 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 node configurations in 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 62 63 64
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, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) 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{ MaxUnavailable: &maxUnavailableSpec, NodeIDs: &listNodeIDsSpec, NodePoolID: "cccccccc-cccc-cccc-cccc-cccccccccccc", } 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 node configurations in 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 74 75 76
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, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cce.NewCceClient(hcClient) request := &model.UpgradeNodePoolRequest{} request.ClusterId = "{cluster_id}" request.NodepoolId = "{nodepool_id}" usernameUserPassword:= "root" userPasswordLogin := &model.UserPassword{ Username: &usernameUserPassword, Password: "xxxxx", } loginNodeTemplate := &model.Login{ UserPassword: userPasswordLogin, } nodeTemplateSpec := &model.NodeTemplate{ Login: loginNodeTemplate, } var listNodeIDsSpec = []string{ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "bbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb", } maxUnavailableSpec:= int32(1) specbody := &model.NodePoolUpgradeSpec{ MaxUnavailable: &maxUnavailableSpec, NodeIDs: &listNodeIDsSpec, NodePoolID: "DefaultPool", NodeTemplate: nodeTemplateSpec, } 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 job information is obtained. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot