Accepting a Node
Function
This API is used to accept a node into a specified cluster.

Constraints
-
ECSs, DeHs, and BMSs can be managed.
-
The nodes to be managed must be running and do not belong to any other clusters. Additionally, the nodes cannot be labeled with CCE-Dynamic-Provisioning-Node.
-
The nodes to be managed must be in the same VPC as the target cluster. If the cluster version is earlier than v1.13.10, the nodes and the cluster must also be in the same subnet.
-
The nodes to be managed must have data disks attached, which can be local disks (disk-intensive disks). Each node should have a data disk of at least 20 GiB attached, and any existing data disks cannot be smaller than 10 GiB.
-
Each of the nodes to be managed has at least 2 vCPUs and 4 GiB of memory and only one ENI bound.
-
If an enterprise project is used, a node to be managed must be in the same enterprise project as the target cluster. Otherwise, resources cannot be identified during node management, ultimately rendering the node unmanageable. In clusters of v1.21.15-r0, v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later versions, the nodes to be managed can be in different enterprise projects from that of the target cluster, and the enterprise projects of these nodes remain unchanged after the nodes are accepted.
-
If IPv6 is enabled for a cluster, only nodes in a subnet with IPv6 enabled can be accepted and managed. If IPv6 is not enabled for the cluster, only nodes in a subnet without IPv6 enabled can be accepted.
-
Nodes in a CCE Turbo cluster must support sub-ENIs, or each of them can have at least 16 ENIs bound. For details about the node flavors, see the node flavors that can be selected on the console when you create a node.
-
Data disks that have been partitioned will be ignored during node management. Ensure that there is at least one unpartitioned data disk meeting the specifications attached to the node.
Calling Method
For details, see Calling APIs.
URI
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/add
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 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Details: The request body type or format Constraints: The GET method is not verified. Options:
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 |
---|---|---|---|
apiVersion |
Yes |
String |
Definition API version Constraints The value is fixed and cannot be changed. Range N/A Default Value v3 |
kind |
Yes |
String |
Definition API type Constraints The value is fixed and cannot be changed. Range N/A Default Value List |
nodeList |
Yes |
Array of AddNode objects |
Definition List of the nodes to be managed Constraints A maximum of 200 nodes can be managed at a time. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
serverID |
Yes |
String |
Definition Server ID, which can be obtained from the ECS or BMS console.
NOTE:
To obtain the server ID, log in to the management console, choose Service List > Compute > Elastic Cloud Server or Bare Metal Server, click the server name, and copy the server ID on the server details page.
Constraints N/A Range N/A Default Value N/A |
spec |
Yes |
ReinstallNodeSpec object |
Definition Node reinstallation parameter settings Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
os |
Yes |
String |
Definition OS. If you specify a private image, the actual OS version of the IMS image is used. Select an OS version supported by the current cluster, for example, Huawei Cloud EulerOS 2.0, Ubuntu 22.04, EulerOS 2.9, CentOS 7.6, and EulerOS 2.8. Constraints N/A Range N/A Default Value N/A |
login |
No |
Login object |
Definition How to log in to a node. If this parameter is not specified, the password of the selected image will be kept. Ensure that you have set a password for the image. Constraints N/A |
name |
No |
String |
Definition Node name. Specifying this field during reinstallation will change the node name, and the server name will change accordingly. By default, the current server name is used as the node name. Constraints The node name must contain 1 to 56 characters that start with a lowercase letter. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed. Range N/A Default Value N/A |
serverConfig |
No |
ReinstallServerConfig object |
Definition Server settings Constraints N/A |
volumeConfig |
No |
ReinstallVolumeConfig object |
Definition Volume management settings Constraints N/A |
runtimeConfig |
No |
ReinstallRuntimeConfig object |
Definition Container runtime settings Constraints N/A |
k8sOptions |
No |
ReinstallK8sOptionsConfig object |
Definition Kubernetes node settings Constraints N/A |
lifecycle |
No |
NodeLifecycleConfig object |
Definition Customized node lifecycle settings Constraints N/A |
initializedConditions |
No |
Array of strings |
Definition Custom initialization flag, which is left empty by default. Before CCE nodes are initialized, node.cloudprovider.kubernetes.io/uninitialized is added to the nodes to prevent pods from being scheduled to these nodes. When managing or resetting a node, you can configure the initializedConditions parameter to control the taint removal time. By default, the timeout period is not configured. Example:
The following is an example of conditions settings: status: conditions: - type: CCEInitial status: 'True' - type: CustomedInitial status: 'True' Constraints
|
extendParam |
No |
ReinstallExtendParam object |
Definition (Deprecated) Extended parameters for reinstallation Constraints N/A |
hostnameConfig |
No |
HostnameConfig object |
Definition Parameter for configuring Kubernetes node name. The supported cluster version is v1.23.6-r0 to v1.25, or v1.25.2-r0 or later. Constraints This parameter is not supported during node resetting. |
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 |
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 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
userTags |
No |
Array of UserTag objects |
Definition Cloud server resource tags Constraints The key of a tag must be unique. The maximum number of custom tags supported by CCE varies depending on regions and cannot exceed 8. |
rootVolume |
No |
ReinstallVolumeSpec object |
Definition System disk reinstallation settings Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Details: Key of the cloud server tag Constraints: The value cannot start with CCE-, __type_baremetal, or sys. Options: The value contains a maximum of 128 characters. The tag key must be unique and cannot start or end with a space. It cannot contain non-printable ASCII characters (0–31) or the following special characters: =*<>,|/ Default value: N/A |
value |
No |
String |
Details: Value of the cloud server tag Constraints: None Options: The value contains a maximum of 255 characters. The tag value cannot start or end with a space. It cannot contain non-printable ASCII characters (0–31) or the following special characters: =*<>,| Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
imageID |
No |
String |
Definition Private image ID.
NOTE:
To obtain the value ID, choose Service List > Compute > Image Management Service, click the Private Image tab, click the image name, and copy the image ID on the page displayed.
Constraints N/A Range N/A Default Value N/A |
cmkID |
No |
String |
Definition CMK ID. If this parameter is left empty, the disk is not encrypted.
NOTE:
For details about how to obtain the key ID, see Querying the Key List.
Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lvmConfig |
No |
String |
Definition (Deprecated) Configuration item of a Docker data disk. Example of the default configuration: "lvmConfig":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear" The following fields are included:
Constraints N/A Range N/A Default Value N/A |
storage |
No |
Storage object |
Details: Disk initialization management parameter. This parameter is complex to configure. For details, see Attaching Disks to a Node. Constraints:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
storageSelectors |
Yes |
Array of StorageSelectors objects |
Details: Disk selection. Matched disks are managed based on matchLabels and storageType settings. Disks are matched in sequence. The matching rule in the front is matched first. Constraints: None |
storageGroups |
Yes |
Array of StorageGroups objects |
Details: A storage group consisting of multiple storage devices, which are used to divide storage space. Constraints: None |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Details: Name of a selector, which is used as the index of selectorNames in storageGroup. Constraints: The name of each selector must be unique. Options: N/A Default value: N/A |
storageType |
Yes |
String |
Details: Storage type Constraints:
Options: Only evs (EVS disks), local (local disks), and system (system disks) are supported. Default value: N/A |
matchLabels |
No |
matchLabels object |
Details: Matching field of an EVS disk Constraints: If storageType is set to system (system disk), you do not need to configure this parameter. Options: The size, volumeType, metadataEncrypted, metadataCmkid, and count fields in DataVolume are supported. Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
size |
No |
String |
Details: Matched disk size, for example, 100. If this parameter is left blank, the disk size is not limited. Constraints: None Options: N/A Default value: N/A |
volumeType |
No |
String |
Definition EVS disk type. Supported types include SSD, GPSSD, SAS, ESSD, and SATA. If this parameter is left empty, there is no restriction on the EVS disk type. Constraints N/A Range N/A Default Value N/A |
metadataEncrypted |
No |
String |
Details: Disk encryption identifier. If this parameter is set to 0, it specifies that the disk is not encrypted. If this parameter is set to 1, it specifies that the disk is encrypted. If this parameter is left blank, there is no restriction on the disk encryption identifier. Constraints: None Options: N/A Default value: N/A |
metadataCmkid |
No |
String |
Details: CMK ID of an encrypted disk. The value is a string of 36 bytes. If this parameter is left blank, there is no restriction on the disk key ID. Constraints: None Options: N/A Default value: N/A |
count |
No |
String |
Details: Number of disks to be selected. If this parameter is left blank, all disks of this type are selected. Constraints: None Options: N/A Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Details: Name of a virtual storage group, which must be unique Constraints: None Options:
Default value: N/A |
cceManaged |
No |
Boolean |
Details: Storage space to which Kubernetes and runtime belong. Only one group is set to true. If this parameter is left blank, the default value false is used. Constraints: None Options: N/A Default value: N/A |
selectorNames |
Yes |
Array of strings |
Details: Corresponds to name in storageSelectors. One group can select multiple selectors, but one selector can be selected by only one group. Constraints: System components cannot be separately stored in the system disk and data disks. Therefore, when the selector type is set to system, only one selector can be selected for a group. |
virtualSpaces |
Yes |
Array of VirtualSpace objects |
Details: Detailed management of space configurations in a group Constraints: None |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Details: Name of a virtualSpace. Only types of share, kubernetes, runtime, and user are supported. Constraints: None Options:
Default value: N/A |
size |
Yes |
String |
Details: Size of a virtualSpace. The value must be an integer in percentage, for example, 90%. Constraints: None Options: 10 to 90. The sum of percentages of all virtualSpaces in a group cannot exceed 100%. Default value: N/A |
lvmConfig |
No |
LVMConfig object |
Details: LVM configuration management, which is applicable to share, Kubernetes, and user space configuration Constraints: One virtualSpace supports only one config. |
runtimeConfig |
No |
RuntimeConfig object |
Details: Runtime configuration management, which is applicable to runtime space configuration Constraints: One virtualSpace supports only one config. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lvType |
Yes |
String |
Details: LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. Constraints: None Options: N/A Default value: N/A |
path |
No |
String |
Details: Disk mount path. This parameter only takes effect in user configuration. The value can be an absolute path containing digits, uppercase letters, lowercase letters, periods (.), hyphens (-), and underscores (_). Constraints: Do not leave the path empty or set it to a key OS path such as the root directory. Key OS paths that cannot be entered: /, /home, /home/, /bin, /bin/, /lib, /lib/, /root, /root/, /boot, /boot/, /dev, /dev/, /etc, /etc/, /lost+found, /lost+found/, /mnt, /mnt/, /proc, /proc/,/sbin, /sbin/, /srv, /srv/, /tmp, /tmp/, /var, /var/, /media, /media/, /opt, /opt/, /selinux, /selinux/, /sys, /sys/, /usr, /usr/, /opt/cloud/, /mnt/paas/, /home/paas/, /var/paas/, /var/lib/, /var/script/ Options: N/A Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lvType |
Yes |
String |
Details: LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. Constraints: None Options: N/A Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
dockerBaseSize |
No |
Integer |
Definition Available disk space of a single container on a node (unit: G). This parameter has been deprecated. Use containerBaseSize. If this parameter is left empty or is set to 0, the default value is used. In Device Mapper mode, the default value is 10. In OverlayFS mode, no fixed upper limit is imposed on the available space of a single container, and the dockerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters of the new versions. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that dockerBaseSize be set to a value less than or equal to 80 GiB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount external or local storage. Constraints N/A Range N/A Default Value N/A |
containerBaseSize |
No |
Integer |
Definition Available disk space of a single container on a node (unit: G). If this parameter is left empty or is set to 0, the default value is used. In OverlayFS mode, no fixed upper limit is imposed on the available space of a single container. In Device Mapper mode, the default value is 10, and the containerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters of v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0, or later. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that containerBaseSize be set to a value less than or equal to 80 GiB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount external or local storage. In new versions, the Device Mapper mode is used only by BMSs in the same resource pool and is being deprecated. Constraints
NOTE:
This parameter cannot be updated when a node pool is being updated.
Range N/A Default Value N/A |
runtime |
No |
Runtime object |
Details: Container runtime
Constraints: None |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Details: Container runtime Constraints: None Options: N/A Default value:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
labels |
No |
Map<String,String> |
Definition Defined in key-value pairs.
Example: "k8sTags": { "key": "value" } Constraints A maximum of 20 key-value pairs is allowed. |
taints |
No |
Array of Taint objects |
Details: Taints, which can be added to nodes for anti-affinity configuration. Each taint contains the following parameters:
When creating a node, you can specify an initial value for this field and this field is not returned during query. In node pools, the initial value can be specified in the node template and this field is returned during query. In other scenarios, this field is not returned during query. Example: "taints": [{ "key": "status", "value": "unavailable", "effect": "NoSchedule" }, { "key": "looks", "value": "bad", "effect": "NoSchedule" }] Constraints: A maximum of 20 taints can be configured. |
maxPods |
No |
Integer |
Definition Maximum number of pods that can be created on a node, including the default pods. This parameter is used to prevent the node from being overloaded due to excessive pods. Set this parameter based on your service requirements. Constraints N/A Range 16 to 256 Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Definition Key of a Kubernetes taint Constraints The value must contain 1 to 63 characters starting and ending with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. Range N/A Default Value N/A |
value |
No |
String |
Definition Value of a Kubernetes taint Constraints The value must contain 1 to 63 characters starting and ending with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. Range N/A Default Value N/A |
effect |
Yes |
String |
Definition Effect of a Kubernetes taint Constraints N/A Range NoSchedule, PreferNoSchedule, and NoExecute Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
preInstall |
No |
String |
Definition Pre-installation script. The characters of both the pre-installation and post-installation scripts are centrally calculated. The input value must be encoded using Base64. The method is as follows: echo -n "*<content-to-be-encoded>*" | base64 Constraints The length cannot exceed 10,240 bytes. Range N/A Default Value N/A |
postInstall |
No |
String |
Definition Pre-installation script. The characters of both the pre-installation and post-installation scripts are centrally calculated. The input value must be encoded using Base64. The method is as follows: echo -n "*<content-to-be-encoded>*" | base64 Constraints The length cannot exceed 10,240 bytes. Range N/A Default Value N/A |
waitPostInstallFinish |
No |
Boolean |
Definition Whether pods can be scheduled onto a node before the post-installation script has completed execution during operations such as node reset, management, and batch reset. If the node belongs to a node pool, the node pool settings apply. If this parameter is not specified or is set to false, pods can be scheduled to an available node after the Kubernetes node is ready. If this parameter is set to true, pods can be scheduled to an available node only after the Kubernetes node is ready and the post-installation script has been executed. Constraints N/A Range
Default Value false |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
alpha.cce/NodeImageID |
No |
String |
Definition (Deprecated) ID of the user image to run the target OS. Specifying this parameter is equivalent to specifying imageID in ReinstallVolumeSpec. The original value will be overwritten. Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Details: Configuration type of the Kubernetes node name. The default value is privateIp. Constraints:
Options:
Default value: privateIp |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
jobid |
String |
Definition ID returned after a job is submitted. This ID can be used to query the execution of the job. Range N/A |
Example Requests
Add a node running EulerOS 2.5 to a cluster.
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/add { "kind" : "List", "apiVersion" : "v3", "nodeList" : [ { "serverID" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "spec" : { "name" : "my-ecs-0001", "os" : "EulerOS 2.5", "login" : { "sshKey" : "KeyPair-001" } } } ] }
Example Responses
Status code: 200
The job for accepting a node into a specified cluster is successfully delivered.
{ "jobid" : "2ec9b78d-9368-46f3-8f29-d1a95622a568" }
SDK Sample Code
The SDK sample code is as follows.
Add a node running EulerOS 2.5 to a cluster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
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.UUID; import java.util.List; import java.util.ArrayList; public class AddNodeSolution { 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(); AddNodeRequest request = new AddNodeRequest(); request.withClusterId("{cluster_id}"); AddNodeList body = new AddNodeList(); Login loginSpec = new Login(); loginSpec.withSshKey("KeyPair-001"); ReinstallNodeSpec specNodeList = new ReinstallNodeSpec(); specNodeList.withOs("EulerOS 2.5") .withLogin(loginSpec) .withName("my-ecs-0001"); List<AddNode> listbodyNodeList = new ArrayList<>(); listbodyNodeList.add( new AddNode() .withServerID(UUID.fromString("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")) .withSpec(specNodeList) ); body.withNodeList(listbodyNodeList); body.withKind("List"); body.withApiVersion("v3"); request.withBody(body); try { AddNodeResponse response = client.addNode(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()); } } } |
Add a node running EulerOS 2.5 to a cluster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 = AddNodeRequest() request.cluster_id = "{cluster_id}" loginSpec = Login( ssh_key="KeyPair-001" ) specNodeList = ReinstallNodeSpec( os="EulerOS 2.5", login=loginSpec, name="my-ecs-0001" ) listNodeListbody = [ AddNode( server_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", spec=specNodeList ) ] request.body = AddNodeList( node_list=listNodeListbody, kind="List", api_version="v3" ) response = client.add_node(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Add a node running EulerOS 2.5 to a cluster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
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.AddNodeRequest{} request.ClusterId = "{cluster_id}" sshKeyLogin:= "KeyPair-001" loginSpec := &model.Login{ SshKey: &sshKeyLogin, } nameSpec:= "my-ecs-0001" specNodeList := &model.ReinstallNodeSpec{ Os: "EulerOS 2.5", Login: loginSpec, Name: &nameSpec, } var listNodeListbody = []model.AddNode{ { ServerID: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", Spec: specNodeList, }, } request.Body = &model.AddNodeList{ NodeList: listNodeListbody, Kind: "List", ApiVersion: "v3", } response, err := client.AddNode(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 for accepting a node into a specified cluster is successfully delivered. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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