Template name
ACS-CS-AttachInstancesToClusterByRunAttachScript: Adds existing ECS nodes to a cluster
Template description
Adds existing Elastic Compute Service (ECS) instances as nodes to a cluster.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
|
Parameter |
Description |
Type |
Required |
Default value |
Limit |
|
targets |
The target ECS instances. |
Json |
Yes |
||
|
clusterId |
The cluster ID. |
String |
Yes |
||
|
regionId |
The region ID. |
String |
No |
{{ ACS::RegionId }} |
|
|
rateControl |
The concurrency settings for task execution. |
Json |
No |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
|
|
OOSAssumeRole |
The RAM role assumed by CloudOps Orchestration Service (OOS). |
String |
No |
"" |
Output parameters
|
Parameter |
Description |
Type |
|
commandOutputs |
List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"cs:DescribeClusterAttachScripts"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-CS-AttachInstancesToClusterByRunAttachScript.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Attach ECS instances to a cluster.
name-en: ACS-CS-AttachInstancesToClusterByRunAttachScript
categories:
- ACK_manage
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Label:
en: TargetInstance
Type: Json
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
clusterId:
Label:
en: ClusterId
Type: String
rateControl:
Label:
en: RateControl
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Views the ECS instances.
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: getAttachScript
Action: 'ACS::ExecuteApi'
Description:
en: Gets the command content for attaching an instance to the cluster.
Properties:
Service: CS
API: DescribeClusterAttachScripts
Method: POST
Headers: {}
URI: '/clusters/{{clusterId}}/attachscript'
Parameters: {}
Body: '{ }'
Outputs:
attachScript:
Type: String
ValueSelector: .data
- Name: runCommand
Action: 'ACS::ECS::RunCommand'
Description:
en: Executes a Cloud Assistant command.
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ getAttachScript.attachScript }}'
instanceId: '{{ ACS::TaskLoopItem }}'
commandType: RunShellScript
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
Outputs:
commandOutputs:
Type: List
Value: '{{ runCommand.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- clusterId
Label:
default:
en: Configure Parameters
- Parameters:
- regionId
- targets
Label:
default:
en: Select Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
en: Control Options