You can call the AttachInstances operation to add existing Elastic Compute Service (ECS) instances to a specified Container Service for Kubernetes (ACK) cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request syntax

POST /clusters/ClusterId/attach HTTP/1.1 
Content-Type:application/json
{
  "instances" : [ "String" ],
  "key_pair" : "String",
  "password" : "String",
  "format_disk" : Boolean,
  "keep_instance_name" : Boolean,
  "is_edge_worker" : Boolean,
  "nodepool_id" : "String",
  "image_id" : "String",
  "cpu_policy" : "String",
  "user_data" : "String",
  "rds_instances" : [ "String" ],
  "runtime" : {
    "name" : "String",
    "version" : "String"
  },
  "tags" : [ {
    "key" : "String",
    "value" : "String"
  } ]
}

Request parameters

Table 1. Request path parameters
Parameter Type Required Example Description
ClusterId String Yes c106f377e16f34eb1808d6b9362c9****

The ID of the cluster.

Table 2. Request body parameters
Parameter Type Required Example Description
instances Array of String Yes i-2zed0sswuau6o89b****

The IDs of the existing ECS instances that you want to add.

key_pair String Yes secrity-key

The name of the key pair that is used to log on to the ECS instances. You must set key_pair or login_password.

Note This parameter is not supported after you specify nodepool_id.
password String Yes Hello1234

The SSH logon password that is used to log on to the ECS instances. You must set login_password or key_pair. The password must be 8 to 30 characters in length, and must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. It cannot contain backslashes (\) or double quotation marks (").

For security considerations, the password is encrypted during data transfer.

format_disk Boolean No false

Specifies whether to store container data and images on data disks. Valid values:

  • true: mounts data disks to store container data and images.
  • false: does not mount data disks to store container data or images.

Default value: false.

How to mount a data disk:

  • If the ECS instances are already mounted with data disks and the file system of the last data disk is not initialized, the system automatically formats this data disk to ext4 and mounts it to /var/lib/docker and /var/lib/kubelet.
  • If no data disk is attached to the ECS instances, the system does not purchase a new data disk.
    Note If you choose to store container data and images on data disks and a data disk is already mounted to the ECS instance, the original data on this data disk will be cleared. You can back up the disk to avoid data loss.
keep_instance_name Boolean No true

Specifies whether to retain the instance name. Valid values:

  • true: retains the instance name.
  • false: does not retain the instance name.

Default value: true

is_edge_worker Boolean No false

Specifies whether the nodes that you want to add are Edge Node Service (ENS) nodes. Valid values:

  • true: The nodes that you want to add are ENS nodes.
  • false: The nodes that you want to add are not ENS nodes.

Default value: false.

Note If the nodes you want to add are ENS nodes, you must set this parameter to true. This allows you to identify these nodes.
nodepool_id String No np615c0e0966124216a0412e10afe0****

The ID of the created node pool. If you do not set this parameter, the nodes are added to the default node pool.

image_id String No aliyun_2_1903_x64_20G_alibase_20200529.vhd

The ID of the custom image. If you do not set this parameter, the default system image is used.

Note
  • If you specify a custom image, the custom image is used to deploy the operating systems on the system disks of the nodes.
  • This parameter is not supported after you specify nodepool_id.
cpu_policy String No none

The CPU management policy. The following policies are supported if the Kubernetes version of the cluster is 1.12.6 or later.

  • static: This policy allows pods with specific resource characteristics on the node to be granted with enhanced CPU affinity and exclusivity.
  • none: indicates that the default CPU affinity is used.

Default value: none

Note This parameter is not supported after you specify nodepool_id.
user_data String No IyEvdXNyL2Jpbi9iYXNoCmVjaG8gIkhlbGxvIEFDSyEi

The user-defined data. For more information, see Generate user-defined data.

Note This parameter is not supported after you specify nodepool_id.
rds_instances Array of String No rm-67yawhau****

The IDs of ApsaraDB RDS instances.

Note This parameter is not supported after you specify nodepool_id.
runtime runtime No

The container runtime.

Note This parameter is not supported after you specify nodepool_id.
tags Array of tag No

The labels that you want to add to nodes. You must add labels based on the following rules:

  • Each label is a case-sensitive key-value pair. You can add up to 20 labels.
  • A key must be unique and cannot exceed 64 characters in length. A value can be empty and cannot exceed 128 characters in length. Keys and values cannot start with aliyun, acs:, https://, or http://. For more information, see Labels and Selectors.
    Note This parameter is not supported after you specify nodepool_id.

Response syntax

HTTP/1.1 200
Content-Type:application/json
{
  "list" : [ {
    "code" : "String",
    "instanceId" : "String",
    "message" : "String"
  } ],
  "task_id" : "String"
}

Response parameters

Table 3. Response body parameters
Parameter Type Example Description
list Array of list

The details of the added nodes.

code String 200

The code that indicates the task result.

instanceId String i-2ze0lgm3y6iylcbt****

The ID of the instance.

message String successful

Indicates whether the ECS instances are successfully added to the ACK cluster.

task_id String T-5a544aff80282e39ea000039

The ID of the task.

Examples

Sample requests

POST /clusters/c106f377e16f34eb1808d6b9362c9****/attach HTTP/1.1 
Content-Type:application/json
{
  "instances" : [ "i-2zed0sswuau6o89b****" ],
  "key_pair" : "secrity-key",
  "password" : "Hello1234",
  "format_disk" : false,
  "keep_instance_name" : true,
  "is_edge_worker" : false,
  "nodepool_id" : "np615c0e0966124216a0412e10afe0****",
  "image_id" : "aliyun_2_1903_x64_20G_alibase_20200529.vhd",
  "cpu_policy" : "none",
  "user_data" : "IyEvdXNyL2Jpbi9iYXNoCmVjaG8gIkhlbGxvIEFDSyEi",
  "rds_instances" : [ "rm-67yawhau****" ],
  "runtime" : {
    "name" : "docker",
    "version" : "19.03.5"
  },
  "tags" : [ {
    "key" : "env",
    "value" : "prod"
  } ]
}

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<list>
    <code>200</code>
    <instanceId>i-2ze0lgm3y6iylcbt****</instanceId>
    <message>successful</message>
</list>
<task_id>T-5a544aff80282e39ea000039</task_id>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, visit the API Error Center.