This topic describes how to add existing Elastic Compute Service (ECS) instances to a cluster.

Note The system disk is replaced in the process of adding ECS instances. Therefore, you need to back up the data in advance.

Request information

Request line

POST /clusters/{cluster_id}/attach HTTP/1.1

Request line parameter (URI Param)

Name Type Required Description
cluster_id String Yes Custer ID

Special request header

None. See Public request headers.

Request body

{
    "password": "the password used by the root account to log on to an ECS instance",
    "instances": "the IDs of the ECS instances that you want to add to the target cluster.",
    "format_disk": "whether to format disks. Value: true|false",
    "key_pair": "the key pair",
    "tags": "the tag added to the node. This is an object of the array format."
}

Request body parsing

Name Type Required Description
password String Yes Password of the ECS instance. The password must be a string of 8 to 30 characters and contain uppercase letters, lowercase letters, numbers, and symbols.
instances Array Yes The IDs of the ECS instances that you want to add to the target cluster.
format_disk Bool No Whether to format a disk.
key_pair String No
Set the name of the a key pair.
  • If you add an ECS instance that runs the Windows OS, ignore this parameter. By default, this parameter is set as null. Any settings of this parameter do not take effect or affect the password.
  • If you add an ECS instance that runs the Linux OS, you can set this parameter. In addition, the password parameter is initialized as forbidden.
tags List No Add a tag to the node.
  • key: indicates the tag name.
  • value: indicates the tag value.

Response information

Response line

HTTP/1.1 202 OK

Special response header

None. See Public response headers.

Response body

{
    "list": [
        {
            "code": "200",
            "instanceId": "i-2zee3oiwcyoz7kwdo8bt",
            "message": "successful"
        },
        {
            "code": "200",
            "instanceId": "i-2ze0lgm3y6iylcbtcypf",
            "message": "successful"
        }
    ],
    "task_id": "T-5a544aff80282e39ea000039"
}

Example

Request example

POST /clusters/Cccfd68c474454665ace07efce924f75f/attach HTTP/1.1
<Public request header>
{
    "password": "Hello1234",
    "tags":[],
    "instances": [
        "i-xxxx",
        "i-yyyy"
    ]
}

Response sample

HTTP/1.1 202 Accepted
<Public response header>
{
    "list": [
        {
            "code": "200",
            "instanceId": "i-xxxx",
            "message": "successful"
        },
        {
            "code": "200",
            "instanceId": "i-yyyy",
            "message": "successful"
        }
    ],
    "task_id": "T-5a544aff80282e39ea000039"
}