Updated on 2024-07-26 GMT+08:00

Accepting a Node

Function

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

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

Calling Method

For details, see Calling APIs.

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes/add

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

cluster_id

Yes

String

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

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format).

X-Auth-Token

Yes

String

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.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

API version. The value is fixed at v3.

kind

Yes

String

API type. The value is fixed at List.

nodeList

Yes

Array of AddNode objects

List of nodes to be managed. A maximum of 200 nodes can be managed simultaneously.

Table 4 AddNode

Parameter

Mandatory

Type

Description

serverID

Yes

String

Server ID, which can be obtained from the ECS or BMS console

spec

Yes

ReinstallNodeSpec object

Node reinstallation configuration parameters. Currently, accepted nodes cannot be added into node pools.

Table 5 ReinstallNodeSpec

Parameter

Mandatory

Type

Description

os

Yes

String

Operating system. If you specify a custom image, the actual OS version in the IMS image is used. Select an OS version supported by the current cluster, for example, EulerOS 2.5, CentOS 7.6, or EulerOS 2.8.

login

Yes

Login object

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

name

No

String

Node name.

NOTE:

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.

Enter 1 to 56 characters starting with a letter and not ending with a hyphen (-).

serverConfig

No

ReinstallServerConfig object

Server configuration.

volumeConfig

No

ReinstallVolumeConfig object

Volume management configuration.

runtimeConfig

No

ReinstallRuntimeConfig object

Container runtime configuration.

k8sOptions

No

ReinstallK8sOptionsConfig object

Kubernetes node configuration.

lifecycle

No

NodeLifecycleConfig object

Customized lifecycle configuration of a node.

initializedConditions

No

Array of strings

Custom initialization flag.

Before CCE nodes are initialized, they are tainted with node.cloudprovider.kubernetes.io/uninitialized to prevent pods from being scheduled to them.

CCE supports custom initialization flags. After receiving the initializedConditions parameter, CCE converts the parameter value into a node label and provisions the label with the node, for example, cloudprovider.openvessel.io/inject-initialized-conditions=CCEInitial_CustomedInitial.

After the node is labeled, its status.Conditions is polled to check whether the type of conditions has a flag name, such as CCEInitial and CustomedInitial. If all input flags exist and their status is True, the node initialization is complete and the initialization taint is removed.

  • Use only letters and digits. Max. characters: 20.

  • Max. flags: 2.

extendParam

No

ReinstallExtendParam object

Extended reinstallation parameter, which is discarded.

hostnameConfig

No

HostnameConfig object

Kubernetes node name configuration parameter, which is supported by clusters of v1.23.6-r0 to v1.25 or clusters of v1.25.2-r0 or later versions.

Table 6 Login

Parameter

Mandatory

Type

Description

sshKey

No

String

Name of the key pair used for login.

userPassword

No

UserPassword object

Password used for node login.

Table 7 UserPassword

Parameter

Mandatory

Type

Description

username

No

String

Login account. The default value is root.

password

Yes

String

If a username and a password are used to create a node, this field is shielded in the response body.

A password must meet the following complexity requirements:

  • Contains 8 to 26 characters.

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

  • Cannot contain the username or the username spelled backwards.

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

Table 8 ReinstallServerConfig

Parameter

Mandatory

Type

Description

userTags

No

Array of UserTag objects

Cloud server labels. The key of a label must be unique. The maximum number of user-defined labels supported by CCE depends on the region. In the region that supports the least number of labels, you can still create up to 5 labels for a cloud server.

rootVolume

No

ReinstallVolumeSpec object

System disk configurations used in reinstallation.

Table 9 UserTag

Parameter

Mandatory

Type

Description

key

No

String

Key of the cloud server label. The value cannot start with CCE- or __type_baremetal.

value

No

String

Value of the cloud server label.

Table 10 ReinstallVolumeSpec

Parameter

Mandatory

Type

Description

imageID

No

String

Custom image ID.

cmkID

No

String

User master key ID. If this parameter is left blank by default, the EVS disk is not encrypted.

Table 11 ReinstallVolumeConfig

Parameter

Mandatory

Type

Description

lvmConfig

No

String

Docker data disk configurations.

The following is an example default configuration:

"lvmConfig":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear"

The following fields are included:

  • userLV: size of the user space, for example, vgpaas/20%VG.

  • userPath: mount path of the user space, for example, /home/wqt-test.

  • diskType: disk type. Currently, only evs, hdd, and ssd are supported.

  • lvType: type of a logic volume. The value can be linear or striped.

  • dockerThinpool: Docker space size, for example, vgpaas/60%VG.

  • kubernetesLV: kubelet space size, for example, vgpaas/20%VG.

storage

No

Storage object

Disk initialization management parameter.

This parameter is complex to configure. For details, see Attaching Disks to a Node.

If this parameter retains its default, disks are managed based on the DockerLVMConfigOverride (discarded) parameter in extendParam. This parameter is supported by clusters of version 1.15.11 and later.

NOTE:
  • If a node has both local and EVS disks attached, make sure to not keep the default value for this parameter, or it may result in unexpected disk partitions.

NOTE:
  • If you want to change the value range of a data disk to 20 to 32768, do not use the default value.

NOTE:
  • If you want to use the shared disk space (with the runtime and Kubernetes partitions cancelled), do not retain the default value of this parameter. For details about the shared disk space, see Data Disk Space Allocation.

Table 12 Storage

Parameter

Mandatory

Type

Description

storageSelectors

Yes

Array of StorageSelectors objects

Disk selection. Matched disks are managed according to matchLabels and storageType.

storageGroups

Yes

Array of StorageGroups objects

A storage group consists of multiple storage devices. It is used to divide storage space.

Table 13 StorageSelectors

Parameter

Mandatory

Type

Description

name

Yes

String

Selector name, used as the index of selectorNames in storageGroup. Therefore, the name of each selector must be unique.

storageType

Yes

String

Storage type. Only evs (EVS disks) and local (local disks) are supported. The local storage does not support disk selection. All local disks will form a VG, so only one storageSelector of the local type is allowed.

matchLabels

No

matchLabels object

Matching field of an EVS volume. The size, volumeType, metadataEncrypted, metadataCmkid and count fields are supported.

Table 14 matchLabels

Parameter

Mandatory

Type

Description

size

No

String

Matched disk size. If this parameter is left unspecified, the disk size is not limited. Example: 100

volumeType

No

String

EVS disk type. SSD, GPSSD, SAS, ESSD, and SATA are supported. If this parameter is left blank, there is no restriction on the disk type.

metadataEncrypted

No

String

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.

metadataCmkid

No

String

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.

count

No

String

Number of disks to be selected. If this parameter is left blank, all disks of this type are selected.

Table 15 StorageGroups

Parameter

Mandatory

Type

Description

name

Yes

String

Name of a virtual storage group, which must be unique.

NOTE:
  • If cceManaged is set to true, the name must be set to vgpaas.

  • If the data disk is used as a temporary storage volume, the name must be vg-everest-localvolume-ephemeral.

  • If the data disk is used as a persistent storage volume, the name must be vg-everest-localvolume-persistent.

cceManaged

No

Boolean

Storage space for Kubernetes and runtime components. Only one group can be set to true. If this parameter is left blank, the default value false is used.

selectorNames

Yes

Array of strings

Corresponds to name in storageSelectors. One group can select multiple selectors, but one selector can be selected by only one group.

virtualSpaces

Yes

Array of VirtualSpace objects

Detailed management of space configuration in a group.

Table 16 VirtualSpace

Parameter

Mandatory

Type

Description

name

Yes

String

Name of a virtualSpace. Options: share, kubernetes, runtime, and user

  • share: shared space configuration (with the runtime and Kubernetes partitions cancelled). lvmConfig needs to be configured.

  • Kubernetes: Kubernetes space configuration. lvmConfig needs to be configured.

  • runtime: runtime space configuration. runtimeConfig needs to be configured.

  • user: user space configuration. lvmConfig needs to be configured.

size

Yes

String

Size of a virtualSpace. The value must be an integer in percentage. Example: 90%.

NOTE:

The sum of the percentages of all virtualSpaces in a group cannot exceed 100%.

lvmConfig

No

LVMConfig object

LVM configuration managements, applicable to the share*, kubernetes, and user spaces. Note that one virtual space supports only one config.

runtimeConfig

No

RuntimeConfig object

runtime configurations, applicable to the runtime space. Note that one virtual space supports only one config.

Table 17 LVMConfig

Parameter

Mandatory

Type

Description

lvType

Yes

String

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.

path

No

String

Path to which the disk is attached. This parameter takes effect only in user configuration. The value is an absolute path. Digits, letters, periods (.), hyphens (-), and underscores (_) are allowed.

Table 18 RuntimeConfig

Parameter

Mandatory

Type

Description

lvType

Yes

String

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.

Table 19 ReinstallRuntimeConfig

Parameter

Mandatory

Type

Description

dockerBaseSize

No

Integer

Available disk space of a single container on a node, in GB. This parameter has been discarded. Use containerBaseSize.

If this parameter is left blank or is set to 0, the default value is used. In Device Mapper mode, the default value is 10. In OverlayFS mode, the available space of a single container is not limited by default, 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 GB. 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 an external or local storage device.

containerBaseSize

No

Integer

Available disk space of a single container on a node, in GB.

If this parameter is left blank or is set to 0, the default value is used. In OverlayFS mode, the available space of a single container is not limited by default. 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 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 GB. 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 an external or local storage device. In new versions, the Device Mapper mode is used only by BMSs in the same resource pool and is being discarded.

runtime

No

Runtime object

Container runtime:

  • Clusters of v1.25 or earlier: docker.

  • Clusters of v1.25 or later: Container runtime varies with the OS. For nodes running EulerOS 2.5 or EulerOS 2.8, the default container runtime is docker. For nodes running other OSs, the default container runtime is containerd.

Table 20 Runtime

Parameter

Mandatory

Type

Description

name

No

String

Container runtime. Default value:

  • Clusters earlier than v1.25: The default value is docker.

  • Clusters of v1.25 or later: The default container runtime varies depending on the OS. For nodes running EulerOS 2.5 or EulerOS 2.8, the default container runtime is docker; for nodes running other OSs, the default container runtime is containerd.

Table 21 ReinstallK8sOptionsConfig

Parameter

Mandatory

Type

Description

labels

No

Map<String,String>

Defined in key-value pairs. A maximum of 20 key-value pairs are allowed.

  • Key: Enter 1 to 63 characters, starting with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. A DNS subdomain can be prefixed to a key and contain a maximum of 253 characters. Example DNS subdomain: example.com/my-key

  • Value: The value can be left blank or contain 1 to 63 characters that start with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed in the character string.

Example:

"k8sTags": {
  "key": "value"
}

taints

No

Array of Taint objects

Taints can be added for anti-affinity when creating nodes. A maximum of 20 taints can be added. Each taint contains the following parameters:

  • Key: A key must contain 1 to 63 characters starting with a letter or digit. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. A DNS subdomain name can be used as the prefix of a key.

  • Value: A value must start with a letter or digit and can contain a maximum of 63 characters, including letters, digits, hyphens (-), underscores (_), and periods (.).

  • Effect: Available options are NoSchedule, PreferNoSchedule, and NoExecute.

Example:

"taints": [{
  "key": "status",
  "value": "unavailable",
  "effect": "NoSchedule"
}, {
  "key": "looks",
  "value": "bad",
  "effect": "NoSchedule"
}]

maxPods

No

Integer

Maximum number of pods that can be created on a node, including the default system pods. Value range: 16 to 256.

This limit prevents the node from being overloaded of pods.

nicMultiqueue

No

String

  • Number of ENI queues. Example setting:

"[{\"queue\":4}]"

The following fields are included:

  • queue: number of ENI queues.

  • This field can be configured only for BMS nodes in a CCE Turbo cluster.

  • Supported proportions are {"1":128, "2":92, "4":92, "8":32, "16":16, "28":9}. That is, if there is one queue, a maximum of 128 ENIs can be bound. If there are two queues, a maximum of 92 ENIs can be bound for two queues.

  • A larger number of ENI queues indicates higher performance but fewer ENIs can be bound. The queue settings cannot be changed after the node pool is created.

nicThreshold

No

String

  • ENI pre-binding thresholds. Example setting:

"0.3:0.6"
  • Low threshold (L): determines the minimum number of pre-bound ENIs (Min). Formula: Min = Total number of ENIs of the node x L

  • High threshold (H): determines the maximum number of pre-bound ENIs (Max). Formula: Max = Total number of ENIs of the node x H

  • Number of ENIs bound to a BMS node (B) and number of ENIs being used by pods (U): U + Min < B < U + Max

  • If the number of pre-bound ENIs on a BMS node is smaller than the minimum allowed, the system will bind more ENIs to make the numbers equal.

  • If the number of pre-bound ENIs on a BMS node is larger than the maximum allowed, the system periodically unbinds ENIs (about every 2 minutes) to make the numbers equal.

  • Both the thresholds are one-decimal-place values ranging from 0.0 to 1.0. The low threshold must be smaller than or equal to the high one.

  • This field can be configured only for BMS nodes in a CCE Turbo cluster.

  • Pre-binding ENIs can speed up workload creation but occupies IP addresses.

Table 22 Taint

Parameter

Mandatory

Type

Description

key

Yes

String

Key.

value

No

String

Value.

effect

Yes

String

Effect.

Table 23 NodeLifecycleConfig

Parameter

Mandatory

Type

Description

preInstall

No

String

Pre-installation script.

NOTE:

The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64)

postInstall

No

String

Post-installation script.

NOTE:

The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64)

Table 24 ReinstallExtendParam

Parameter

Mandatory

Type

Description

alpha.cce/NodeImageID

No

String

(Discarded) 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.

Table 25 HostnameConfig

Parameter

Mandatory

Type

Description

type

Yes

String

Configuration type of the Kubernetes node name. The default value is privateIp.

  • privateIp: The Kubernetes node is named after its IP address.

  • cceNodeName: The Kubernetes node is named after the CCE node.

NOTE:
  • For a node which is configured using cceNodeName, the name is the same as the Kubernetes node name and the ECS name. The node name cannot be changed. If the ECS name is changed on the ECS console, the node name will retain unchanged after ECS synchronization.

  • For a node which is configured using cceNodeName, to avoid a conflict between Kubernetes nodes, the system automatically adds a suffix to each node name. The suffix is in the format of A hyphen (-) Five random characters. The value of the random characters is a lowercase letter or a digit ranging from 0 to 9.

Response Parameters

Status code: 200

Table 26 Response body parameters

Parameter

Type

Description

jobid

String

Job ID returned after the job is delivered. The job ID can be used to query the job execution status.

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.