-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-swarm.yaml
More file actions
327 lines (308 loc) · 11.8 KB
/
docker-swarm.yaml
File metadata and controls
327 lines (308 loc) · 11.8 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
heat_template_version: 2013-05-23
description: 'Docker Swarm'
parameters:
flavor:
type: string
description: 'Flavor to be used for compute instance'
key_name:
type: string
description: 'For most clouds, the name of the key-pair to be used for the compute instance; for VMware clouds, the contents of the public SSH key for the compute instance'
availability_zone:
type: string
description: 'Name of availability zone in which to create the instance'
default: 'nova'
worker:
type: string
description: 'OS Image for the Docker Swarm Worker Servers'
label: Worker
default:
ucd_server_url:
type: string
description: 'The server URL for agent communication to UrbanCode Deploy. Do *not* add a trailing slash.'
default: 'http://192.168.27.100:8080'
ucd_user:
type: string
description: 'The user credential for the UrbanCode Deploy server.'
default: 'PasswordIsAuthToken'
ucd_password:
type: string
description: 'The user credential for the UrbanCode Deploy server.'
hidden: true
ucd_relay_url:
type: string
description: 'The server URL for an agent relay - leave as ''None'' to enable agents to communicate with server directly.'
default: 'None'
manager:
type: string
description: 'OS Image for the Docker Swarm Manager Servers'
label: Manager
private_network:
default: private_network
type: string
label: 'Private Network'
description: 'Generated to reference ''private'' network.'
public_network_id:
type: string
description: 'Generated for floating IP'
default: 'public_network_id'
parameter_groups:
- { label: 'Agent Parameters', parameters: [ucd_password, ucd_relay_url, ucd_server_url, ucd_user] }
- { label: 'Image Parameters', parameters: [flavor, key_name, manager, worker] }
- { label: 'Network Parameters', parameters: [availability_zone, private_network, public_network_id] }
resources:
docker-swarm-sg:
type: OS::Neutron::SecurityGroup
properties:
name: Docker Swarm Security Group
rules:
- direction: ingress
port_range_min: 22
port_range_max: 22
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 2375
port_range_max: 2375
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 2376
port_range_max: 2376
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 2377
port_range_max: 2377
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 7946
port_range_max: 7946
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 7946
port_range_max: 7946
protocol: udp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 4789
port_range_max: 4789
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 4789
port_range_max: 4789
protocol: udp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 4000
port_range_max: 4000
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 8500
port_range_max: 8500
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 80
port_range_max: 80
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 8080
port_range_max: 8080
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 9080
port_range_max: 9080
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
- direction: ingress
port_range_min: 8001
port_range_max: 8002
protocol: tcp
ethertype: IPv4
remote_ip_prefix: 0.0.0.0/0
docker-swarm-worker-asg:
type: OS::Heat::AutoScalingGroup
properties:
min_size: 3
max_size: 20
resource:
type: ./nested/docker-swarm_worker.yaml
properties:
environment_name: { get_attr: [resource_tree, environment_name ] }
application_name: { get_attr: [resource_tree, application_name ] }
docker-swarm-sg: { get_resource: docker-swarm-sg }
ucd_relay_url: { get_param: ucd_relay_url }
ucd_password: { get_param: ucd_password }
ucd_user: { get_param: ucd_user }
ucd_server_url: { get_param: ucd_server_url }
private_network: {get_param: private_network }
worker: { get_param: worker }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
availability_zone: { get_param: availability_zone }
docker-swarm-manager-asg:
type: OS::Heat::AutoScalingGroup
properties:
min_size: 1
max_size: 5
resource:
type: nested/docker-swarm_manager.yaml
properties:
environment_name: { get_attr: [resource_tree, environment_name ] }
application_name: { get_attr: [resource_tree, application_name ] }
docker-swarm-sg: { get_resource: docker-swarm-sg }
ucd_relay_url: { get_param: ucd_relay_url }
ucd_password: { get_param: ucd_password }
ucd_user: { get_param: ucd_user }
ucd_server_url: { get_param: ucd_server_url }
private_network: {get_param: private_network }
public_network_id: {get_param: public_network_id }
manager: { get_param: manager }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
availability_zone: { get_param: availability_zone }
docker-swarm-master-srv:
type: OS::Nova::Server
properties:
networks:
- port: { get_resource: master-srv__to__private__port }
user_data: {get_resource: master-srv_mime}
user_data_format: RAW
image: { get_param: manager }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
availability_zone: { get_param: availability_zone }
metadata:
"__os_type__" : "Linux"
### metering ###
master-srv__to__private__port__floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: { get_param: public_network_id }
port_id: { get_resource: master-srv__to__private__port }
master-srv__to__private__port:
type: OS::Neutron::Port
properties:
security_groups:
- { get_resource: docker-swarm-sg }
network_id: {get_param: private_network } # Generated to reference a network
replacement_policy: AUTO #TODO remove this if using HEAT version Icehouse!
docker-engine1:
type: IBM::UrbanCode::SoftwareDeploy::UCD
properties:
apply_config: { get_resource: docker-engine_sw_config1 }
server: docker-swarm-master-srv
version: '1.13'
agent_timeout: "720"
docker-engine_sw_config1:
type: IBM::UrbanCode::SoftwareConfig::UCD
properties:
name: "docker-engine"
component_process: 'install docker-engine'
component_process_timeout: "600"
ucd_server_url: { get_param: ucd_server_url } # these should come from resource_tree
ucd_username: { get_param: ucd_user }
ucd_password: { get_param: ucd_password }
application: { get_attr: [resource_tree, application_name] }
environment_name: { get_attr: [resource_tree, environment_name] }
master-srv_mime:
type: OS::Heat::MultipartMime
properties:
parts:
- config: { get_resource: ucd_agent_install_linux }
subtype: "x-shellscript"
docker-engine:
depends_on: docker-engine1
type: IBM::UrbanCode::SoftwareDeploy::UCD
properties:
apply_config: { get_resource: docker-engine_sw_config }
server: docker-swarm-master-srv
version: '1.13'
agent_timeout: "720"
docker-engine_sw_config:
type: IBM::UrbanCode::SoftwareConfig::UCD
properties:
name: "docker-engine"
component_process: 'create new docker swarm'
component_process_timeout: "600"
ucd_server_url: { get_param: ucd_server_url } # these should come from resource_tree
ucd_username: { get_param: ucd_user }
ucd_password: { get_param: ucd_password }
application: { get_attr: [resource_tree, application_name] }
environment_name: { get_attr: [resource_tree, environment_name] }
inputs:
swarm-master-public-ip: { get_attr: [ master-srv__to__private__port__floating_ip, floating_ip_address ] }
swarm-master-public-hostname: { get_attr: [ docker-swarm-master-srv, name ] }
resource_tree:
type: IBM::UrbanCode::ResourceTree
properties:
urbancode_deploy_url: { get_param: ucd_server_url }
username: { get_param: ucd_user }
password: { get_param: ucd_password }
team_mappings:
application: docker-swarm-mode
base_resource_group: DOCKER_SWARM_01
ucd_agent_install_linux:
type: OS::Heat::SoftwareConfig
properties:
config:
str_replace:
template: |
#!/usr/bin/env bash
#ifconfig eth0 mtu 1454 ## Optionally patch the MTU
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/root/bin
arch=`uname -ms | awk '{print tolower($0)}' | tr " " "-" `
agent_archive=ibm-ucd-agent-$arch.tgz
if [ "_ucd_relay_url_" != "None" ]; then
proxy_args="--proxy _ucd_relay_url_:20080"
ucd_remote_host=_ucd_relay_url_
agent_args="-r -d"
ucd_jms_port=7916
else
proxy_args=
agent_args=
ucd_remote_host=_ucd_server_url_
ucd_jms_port=7918
fi
if command -V apt-get && ! command -V curl; then apt-get -y install curl; fi
if command -V yum && ! command -V curl; then yum -y install curl; fi
curl $proxy_args -Lk --retry 10 --retry-delay 10 --retry-max-time 120 -o /tmp/$agent_archive -u _ucd_user_:_ucd_password_ "_ucd_server_url_/cli/version/downloadArtifacts?component=ucd-agent-$arch&version=_agent_version_&singleFilePath=$agent_archive"
tar xfz /tmp/$agent_archive -C /tmp
/tmp/ibm-ucd-agent-install/install-agent-with-options.sh -t "_agent_team_" -p $ucd_jms_port -s $ucd_remote_host $agent_args -x start -v -n _agent_name_
params:
_agent_name_:
str_replace:
template: |
"_application_name_._environment_name_"
params:
_application_name_: { get_attr: [resource_tree, application_name ] }
_environment_name_: { get_param: "OS::stack_name" }
_ucd_server_url_: { get_param: ucd_server_url }
_ucd_relay_url_: { get_param: ucd_relay_url }
_ucd_user_ : { get_param: ucd_user }
_ucd_password_ : { get_param: ucd_password }
_agent_version_ : 7.1
_agent_team_ : ""
outputs:
blueprint_url:
description: Blueprint Origin URL
value: http://192.168.27.100:9080/landscaper/view/projects?open=demo_fac59e2a_9b9f_4618_a93b_17ba6e2cf20c-OrionContent/swarm-blueprint/docker-swarm.yml