forked from qubell-bazaar/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-ecs.yml
136 lines (133 loc) · 4.85 KB
/
docker-ecs.yml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
application:
interfaces:
cluster-config:
'*': bind(cluster#input.*)
docker:
'*': bind(docker-service-adapter#docker.*)
cluster-info:
'*': bind(cluster#result.*)
configuration:
cluster-config.zone:
zone: us-east-1
image: us-east-1/ami-b540eade
cluster-config.instance-type: m3.medium
cluster-config.size: 1
bindings:
- [aws-ca, cluster]
- [aws-ca, docker-service-adapter]
- [cluster, docker-service-adapter]
components:
aws-ca:
type: reference.Service
interfaces:
dynamic:
amazon-api-call: receive-command(string method, string endpoint, map<string, string> headers, string body => string body)
docker-service-adapter:
type: cobalt.docker.AmazonEcsService
cluster:
type: workflow.Instance
interfaces:
input:
zone:
type: configuration(map<string,string>)
suggestions:
us-east-1:
zone: us-east-1
image: us-east-1/ami-b540eade
eu-west-1:
zone: eu-west-1
image: eu-west-1/ami-2aaef35d
instance-type:
type: configuration(string)
suggestions:
m3.medium: m3.medium
c3.large: c3.large
size: configuration(int)
aws-ca:
amazon-api-call: send-command(string method, string endpoint, map<string, string> headers, string body => string body)
result:
ecs-cluster-name: publish-signal(string)
ecs-cluster-arn: publish-signal(string)
ecs-cluster-nodes: publish-signal(list<string>)
ecs-cluster-zone: publish-signal(string)
required: [aws-ca]
configuration:
configuration.propagateStatus: [update]
configuration.triggers:
input.size: update
configuration.workflows:
launch:
steps:
- get-instance-id:
action: getInstanceContext
output:
instanceId: instanceId
- create-cluster:
action: aws-ca.amazon-api-call
precedingPhases: [ get-instance-id ]
parameters:
method: POST
endpoint: http://ecs.{$.zone.zone}.amazonaws.com/
headers:
X-Amz-Target: AmazonEC2ContainerServiceV20141113.CreateCluster
Content-Type: application/x-amz-json-1.1
body: ' {{ "clusterName": "tonomi-cluster-{$.instanceId}" }} '
output:
create-response: body
- scale: &scale-step
action: provisionVms
precedingPhases: [ create-cluster ]
parameters:
imageId: '{$.zone.image}'
hardwareId: '{$.instance-type}'
targetQuantity: '{$.size}'
retryCount: 3
providerSettings:
iamRole: ecsInstanceRole
userData:
|
#!/bin/bash
echo ECS_CLUSTER=tonomi-cluster-{$.instanceId} >> /etc/ecs/ecs.config
output:
ips: ips
return:
ecs-cluster-arn:
value: "{$.create-response.cluster.clusterArn}"
ecs-cluster-name:
value: "{$.create-response.cluster.clusterName}"
ecs-cluster-zone:
value: "{$.zone.zone}"
ecs-cluster-nodes:
value: "{$.ips}"
update:
steps:
- get-instance-id:
action: getInstanceContext
output:
instanceId: instanceId
- create-cluster:
action: wait
parameters:
delay: 0 seconds
- scale: *scale-step
return:
ecs-cluster-nodes:
value: "{$.ips}"
destroy:
steps:
- kill-vms:
action: undeployEnv
- get-instance-id:
action: getInstanceContext
output:
instanceId: instanceId
- destroy-cluster:
action: aws-ca.amazon-api-call
precedingPhases: [ kill-vms, get-instance-id ]
parameters:
method: POST
endpoint: http://ecs.{$.zone.zone}.amazonaws.com/
headers:
X-Amz-Target: AmazonEC2ContainerServiceV20141113.DeleteCluster
Content-Type: application/x-amz-json-1.1
body: ' {{ "cluster": "tonomi-cluster-{$.instanceId}" }} '