This repository has been archived by the owner on Dec 30, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
advanced-openstack-haproxy-blueprint.yaml
431 lines (368 loc) · 13.1 KB
/
advanced-openstack-haproxy-blueprint.yaml
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
tosca_definitions_version: cloudify_dsl_1_3
description: >
This Blueprint installs the nodecellar application behind
an haproxy instance on an openstack cloud environment.
imports:
- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
- http://www.getcloudify.org/spec/openstack-plugin/2.0/plugin.yaml
- http://www.getcloudify.org/spec/diamond-plugin/1.3.3/plugin.yaml
- types/nodecellar.yaml
- types/advanced-openstack-types.yaml
- types/haproxy/haproxy.yaml
- types/scale/scale.yaml
#####################################################################################
# inputs section allows the user to use same
# blueprint for creating different deployments, each one
# with its own parameters.
# to specify deployment inputs run:
# - cfy deployments create -b <blueprint_id> -d <deployment_id> -i inputs.json
#####################################################################################
inputs:
keystone_username:
default: ''
type: string
keystone_password:
default: ''
type: string
keystone_tenant_name:
default: ''
type: string
keystone_url:
default: ''
type: string
region:
default: ''
type: string
openstack_config:
default:
username: { get_input: keystone_username }
password: { get_input: keystone_password }
tenant_name: { get_input: keystone_tenant_name }
auth_url: { get_input: keystone_url }
region: { get_input: region }
key_name:
default: nodecellar
private_key_path:
default: ~/.ssh/nodecellar.pem
external_network_name:
default: external
router_name:
description: The Router Name
public_network_name:
description: The name of the Openstack public network.
private_network_name:
description: The name of the Openstack private network.
public_subnet_name:
description: The name of the public network subnet.
private_subnet_name:
description: The name of the private network subnet.
image_id:
description: >
An Openstack Image ID. Tested with a Ubuntu 14.04 image.
flavor_id:
description: >
An Openstack Flavor ID.
agent_user:
description: The user name of the agent on the instance created from the image_id.
default: ubuntu
node_templates:
nodecellar:
type: nodecellar.nodes.NodecellarApplicationModule
relationships:
################################
# Setting the mongo connection
################################
- type: node_connected_to_mongo
target: mongod
################################
# Setting the nodejs connection
################################
- type: node_contained_in_nodejs
target: nodejs
################################
# Setting the haproxy connection
################################
- type: app_connected_to_haproxy
target: haproxy
mongod:
type: nodecellar.nodes.MonitoredMongoDatabase
relationships:
- type: cloudify.relationships.contained_in
target: mongod_host
nodejs:
type: nodecellar.nodes.NodeJSServer
relationships:
- type: cloudify.relationships.contained_in
target: nodejs_host
########################################
# Note: only ubuntu haproxy installation
# is supported.
########################################
haproxy:
type: nodecellar.nodes.MonitoredHAProxy
properties:
backend_app_port: { get_property: [ nodecellar, port ] }
relationships:
- target: haproxy_frontend_host
type: cloudify.relationships.contained_in
mongod_host:
type: nodecellar.nodes.MonitoredServer
properties:
management_network_name: { get_property: [ private_network, resource_id ] }
relationships:
- target: mongodb_host_port
type: cloudify.openstack.server_connected_to_port
- type: cloudify.openstack.server_connected_to_keypair
target: key
nodejs_host:
type: nodecellar.nodes.MonitoredServer
###########################################################
# Setting the nodejs_host initial number of instances to 2.
# The default values for instances.deploy is 1.
###########################################################
instances:
deploy: 2
properties:
management_network_name: { get_property: [ private_network, resource_id ] }
relationships:
- target: nodejs_host_port
type: cloudify.openstack.server_connected_to_port
- type: cloudify.openstack.server_connected_to_keypair
target: key
haproxy_frontend_host:
type: nodecellar.nodes.MonitoredServer
relationships:
- target: haproxy_host_port
type: cloudify.openstack.server_connected_to_port
- type: cloudify.openstack.server_connected_to_keypair
target: key
mongodb_host_port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: { get_input: openstack_config }
relationships:
- type: cloudify.relationships.contained_in
target: private_network
- type: cloudify.relationships.depends_on
target: private_subnet
- type: cloudify.openstack.port_connected_to_security_group
target: mongod_security_group
nodejs_host_port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: { get_input: openstack_config }
relationships:
- type: cloudify.relationships.contained_in
target: private_network
- type: cloudify.relationships.depends_on
target: private_subnet
- type: cloudify.openstack.port_connected_to_security_group
target: nodecellar_security_group
haproxy_host_port:
type: cloudify.openstack.nodes.Port
properties:
openstack_config: { get_input: openstack_config }
relationships:
- type: cloudify.relationships.contained_in
target: public_network
- type: cloudify.relationships.depends_on
target: public_subnet
- type: cloudify.openstack.port_connected_to_security_group
target: haproxy_frontend_security_group
- type: cloudify.openstack.port_connected_to_floating_ip
target: nodecellar_ip
###########################################################
# A security group to enable access to the mongo host
# using the port of the mongo node.
#
# We need this so that the nodecellar application can
# comminicate with MongoDB, since they are running on
# different hosts.
###########################################################
mongod_security_group:
type: cloudify.openstack.nodes.SecurityGroup
properties:
openstack_config: { get_input: openstack_config }
security_group:
name: mongod_security_group
rules:
- remote_ip_prefix: 0.0.0.0/0
port: 22
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ mongod, port ] }
- remote_ip_prefix: 0.0.0.0/0
port: 28017
###########################################################
# A security group to enable access to the nodejs host
# using the port of the nodecellar application.
#
# This security group will be attached to the nodejs_host
###########################################################
nodecellar_security_group:
type: cloudify.openstack.nodes.SecurityGroup
properties:
openstack_config: { get_input: openstack_config }
security_group:
name: nodecellar_security_group
rules:
- remote_ip_prefix: 0.0.0.0/0
port: 22
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ nodecellar, port ] }
###########################################################
# A security group to enable access to the haproxy frontend
# host using the haproxy frontend_port property.
# In addition, we open the statistics port (9000) of haproxy
#
# This security group will be attached to the
# haproxy_frontend_host
###########################################################
haproxy_frontend_security_group:
type: cloudify.openstack.nodes.SecurityGroup
properties:
openstack_config: { get_input: openstack_config }
security_group:
name: haproxy_frontend_security_group
rules:
- remote_ip_prefix: 0.0.0.0/0
port: 22
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ haproxy, frontend_port ] }
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ haproxy, statistics_port ]}
###########################################################
# An ip to be attached to the haproxy frontend host, since
# eventually we want to be able to access it
# from any machine, on any network.
###########################################################
nodecellar_ip:
type: cloudify.openstack.nodes.FloatingIP
properties:
openstack_config: { get_input: openstack_config }
floatingip:
floating_network_name: { get_property: [ external_network, resource_id ] }
private_subnet:
type: cloudify.openstack.nodes.Subnet
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: private_subnet_name }
relationships:
- target: private_network
type: cloudify.relationships.contained_in
private_network:
type: cloudify.openstack.nodes.Network
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: private_network_name }
public_subnet:
type: cloudify.openstack.nodes.Subnet
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: public_subnet_name }
relationships:
- target: public_network
type: cloudify.relationships.contained_in
- target: router
type: cloudify.openstack.subnet_connected_to_router
public_network:
type: cloudify.openstack.nodes.Network
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: public_network_name }
router:
type: cloudify.openstack.nodes.Router
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: router_name }
relationships:
- target: external_network
type: cloudify.relationships.connected_to
external_network:
type: cloudify.openstack.nodes.Network
properties:
openstack_config: { get_input: openstack_config }
use_external_resource: true
resource_id: { get_input: external_network_name }
key:
type: cloudify.openstack.nodes.KeyPair
properties:
openstack_config: { get_input: openstack_config }
resource_id: { get_input: key_name }
private_key_path: { get_input: private_key_path }
###########################################################
# This outputs section exposes the application endpoint.
# You can access it by running:
# - cfy deployments -d <deployment_id> outputs
###########################################################
outputs:
endpoint:
description: Web application endpoint
value:
ip_address: { get_attribute: [ nodecellar_ip, floating_ip_address ] }
port: { get_property: [haproxy, frontend_port] }
groups:
nodejs_host_scale_group:
members: [nodejs_host, nodejs_host_port]
scale_up_group:
members: [nodejs_host]
policies:
auto_scale_up:
type: scale_policy_type
properties:
policy_operates_on_group: true
scale_limit: 6
scale_direction: '<'
scale_threshold: 6
service_selector: .*nodejs_host.*.process.node.cpu.percent
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: 1
node_id: nodecellar
scale_compute: true
scale_down_group:
members: [nodejs_host]
policies:
auto_scale_down:
type: scale_policy_type
properties:
scale_limit: 2
scale_direction: '>'
scale_threshold: 1
service_selector: .*nodejs_host.*.process.node.cpu.percent
cooldown_time: 60
triggers:
execute_scale_workflow:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: scale
workflow_parameters:
delta: -1
node_id: nodecellar
scale_compute: true
heal_group:
members: [nodejs_host]
policies:
simple_autoheal_policy:
type: cloudify.policies.types.host_failure
properties:
service:
- .*nodejs_host.*.cpu.total.system
interval_between_workflows: 60
triggers:
auto_heal_trigger:
type: cloudify.policies.triggers.execute_workflow
parameters:
workflow: heal
workflow_parameters:
node_instance_id: { 'get_property': [ SELF, node_id ] }
diagnose_value: { 'get_property': [ SELF, diagnose ] }