All Products
Search
Document Center

Container Service for Kubernetes:AttachInstances

Last Updated:Mar 26, 2025

Adds existing Elastic Compute Service (ECS) instances to a Container Service for Kubernetes (ACK) cluster. When you need to add an ECS instance as a worker node to an ACK cluster or re-add a worker node to the cluster, you can call this operation.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
cs:AttachInstancesupdate
*Cluster
acs:cs:{#regionId}:{#accountId}:cluster/{#ClusterId}
    none
none

Request syntax

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

Request parameters

ParameterTypeRequiredDescriptionExample
ClusterIdstringYes

The cluster ID.

c106f377e16f34eb1808d6b9362c9****
bodyobjectNo

The request body parameters.

instancesarrayYes

The ECS instances that you want to add.

stringNo

The ECS instance ID.

i-2zed0sswuau6o89b****
key_pairstringNo

The name of the key pair used to log on to the ECS instances. You must specify this parameter or login_password.

Note This parameter is not supported if you specify nodepool_id.
secrity-key
passwordstringNo

The SSH logon password used to log on to the ECS instances. You must specify this parameter 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. The password cannot contain backslashes (\) or double quotation marks (").

The password is encrypted during data transfer to ensure security.

Hello1234
format_diskbooleanNo

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

  • true: stores container data and images on data disks.
  • false: does not store container data or images on data disks.

Default value: false.

How data disks are attached:

  • If the ECS instance is already attached with data disks and the file system of the last data disk is not initialized, the system automatically formats this data disk to ext4. Then, the system uses the disk to store the data in the /var/lib/docker and /var/lib/kubelet directories.
  • If no data disk is attached to the ECS instance, 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 attached to the ECS instance, the original data on this data disk is cleared. You can back up the disk to prevent data loss.
false
keep_instance_namebooleanNo

Specifies whether to retain the instance name. Valid value:

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

Default value: false.

true
is_edge_workerbooleanNo

Specifies whether the node that you want to add is an Edge Node Service (ENS) node. Valid value:

  • true: the node that you want to add is an ENS node.
  • false: the node that you want to add is not an ENS node.

Default value: false.

Note If the node that you want to add is an ENS node, you must set the value to true. This allows you to identify the node.
false
nodepool_idstringNo

The ID of the node pool to which the node is added. If you do not specify this parameter, the node is added to the default node pool.

np615c0e0966124216a0412e10afe0****
image_idstringNo

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

Note
  • If you specify a custom image, the custom image is used to deploy the operating system on the system disk of the node.

  • This parameter is not supported if you specify nodepool_id.

aliyun_2_1903_x64_20G_alibase_20200529.vhd
cpu_policystringNo

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

  • static: allows pods with specific resource characteristics on the node to be granted enhanced CPU affinity and exclusivity.
  • none: uses default CPU affinity.

Default value: none

Note This parameter is not supported if you specify nodepool_id.
none
user_datastringNo

The user-defined data on the node. For more information, see Use instance user data to automatically run commands or scripts on instance startup.

Note This parameter is not supported if you specify nodepool_id.
IyEvdXNyL2Jpbi9iYXNoCmVjaG8gIkhlbGxvIEFDSyEi
rds_instancesarrayNo

A list of ApsaraDB RDS instances.

stringNo

The ApsaraDB RDS instance ID.

Note This parameter is not supported if you specify nodepool_id.
rm-67yawhau****
runtimeruntimeNo

The container runtime.

Note This parameter is not supported if you specify nodepool_id.
tagsarrayNo

The labels that you want to add to the node. When you add labels to a node, the following rules apply:

  • A label is a case-sensitive key-value pair. You can add up to 20 labels.
  • The key must be unique and cannot exceed 64 characters in length. The 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 if you specify nodepool_id.
tagNo

The labels that you want to add to the node.

Response parameters

ParameterTypeDescriptionExample
object

The response body.

listarray<object>

The details of the added nodes.

listobject
codestring

The code that indicates the task result.

200
instanceIdstring

The ID of the ECS instance.

i-2ze0lgm3y6iylcbt****
messagestring

Indicates whether the ECS instance is successfully added to the ACK cluster.

successful
task_idstring

The task ID.

T-5a544aff80282e39ea000039

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history