forked from cloudify-cosmo/cloudify-nodecellar-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvcloud-haproxy-blueprint.yaml
388 lines (320 loc) · 12.1 KB
/
vcloud-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
###########################################################
# This Blueprint installs the nodecellar application behind
# an haproxy instance on an vcloud cloud environment.
###########################################################
tosca_definitions_version: cloudify_dsl_1_0
imports:
- http://www.getcloudify.org/spec/cloudify/3.3m3/types.yaml
- http://www.getcloudify.org/spec/diamond-plugin/1.3m3/plugin.yaml
- https://raw.githubusercontent.com/cloudify-cosmo/tosca-vcloud-plugin/master/plugin.yaml
- types/nodecellar.yaml
- types/haproxy.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.yaml
#####################################################################################
inputs:
catalog:
description: >
The vCloud catalog
default: ''
template:
description: >
The vCloud template
default: ''
agent_user:
description: >
User name used when SSH-ing into the started machine
default: ubuntu
management_network_name:
description: >
Name of the existing network that's being used for Cloudify management
type: string
application_network_name:
description: >
Name for the new network that will be used as application network
type: string
default: nodecellar-network
ip_allocation_mode:
type: string
default: pool
edge_gateway:
description: >
The edge gateway ID
type: string
server_cpu:
default: 2
description: >
cpu count for each server
server_memory:
default: 4096
description: >
memory amount for each server
agent_public_key:
type: string
node_types:
nodecellar.nodes.AppNetwork:
derived_from: cloudify.vcloud.nodes.Network
properties:
network:
default:
edge_gateway: { get_input: edge_gateway }
name: { get_input: application_network_name }
static_range: 10.0.0.2-10.0.0.128
netmask: 255.255.255.0
gateway_ip: 10.0.0.1
dns: ['10.0.0.1', '8.8.8.8']
dhcp:
dhcp_range: 10.0.0.129-10.0.0.254
default_lease: 3600
max_lease: 7200
nodecellar.nodes.MonitoredServer:
derived_from: cloudify.vcloud.nodes.Server
properties:
cloudify_agent:
default:
user: { get_input: agent_user }
home_dir: /home/ubuntu
server:
default:
catalog: { get_input: catalog }
template: { get_input: template }
hardware:
cpu: { get_input: server_cpu }
memory: { get_input: server_memory }
guest_customization:
public_keys:
-
key: { get_input: agent_public_key }
user: { get_input: agent_user }
management_network:
default: { get_input: management_network_name }
interfaces:
###########################################################
# We are infact telling cloudify to install a diamond
# monitoring agent on the server.
#
# (see https://github.com/BrightcoveOS/Diamond)
###########################################################
cloudify.interfaces.monitoring_agent:
install:
implementation: diamond.diamond_agent.tasks.install
inputs:
diamond_config:
default:
interval: 1
start: diamond.diamond_agent.tasks.start
stop: diamond.diamond_agent.tasks.stop
uninstall: diamond.diamond_agent.tasks.uninstall
###########################################################
# Adding some collectors. These collectors are necessary
# for the Cloudify UI to display the default metrics.
###########################################################
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
default:
CPUCollector: {}
MemoryCollector: {}
LoadAverageCollector: {}
DiskUsageCollector:
config:
devices: x?vd[a-z]+[0-9]*$
NetworkCollector: {}
node_templates:
management_network:
type: cloudify.vcloud.nodes.Network
properties:
use_external_resource: true
resource_id: { get_input: management_network_name }
management_network_port:
type: cloudify.vcloud.nodes.Port
properties:
port:
network: { get_input: management_network_name }
ip_allocation_mode: { get_input: ip_allocation_mode }
primary_interface: false
app_network:
type: nodecellar.nodes.AppNetwork
relationships:
###########################################################
# Bring internet access for application network
###########################################################
- target: app_network_internet_access
type: cloudify.vcloud.net_connected_to_public_nat
app_network_port:
type: cloudify.vcloud.nodes.Port
properties:
port:
network: { get_input: application_network_name }
ip_allocation_mode: { get_input: ip_allocation_mode }
primary_interface: true
relationships:
###########################################################
# Connect port to network so network will be created first
###########################################################
- target: app_network
type: cloudify.vcloud.port_connected_to_network
app_network_internet_access:
type: cloudify.vcloud.nodes.PublicNAT
properties:
nat:
edge_gateway: { get_input: edge_gateway }
rules:
type:
- SNAT
mongod_host:
type: nodecellar.nodes.MonitoredServer
relationships:
###########################################################
# Connecting network interfaces to the mongo host
###########################################################
- target: app_network_port
type: cloudify.vcloud.server_connected_to_port
- target: management_network_port
type: cloudify.vcloud.server_connected_to_port
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
relationships:
###########################################################
# Connecting network interfaces to the nodecellar host
###########################################################
- target: app_network_port
type: cloudify.vcloud.server_connected_to_port
- target: management_network_port
type: cloudify.vcloud.server_connected_to_port
haproxy_frontend_host:
type: nodecellar.nodes.MonitoredServer
relationships:
###########################################################
# Attaching a floating ip to the haproxy frontend host
###########################################################
- type: cloudify.vcloud.server_connected_to_floating_ip
target: frontend_floatingip
###########################################################
# Connecting network interfaces to the haproxy frontend host
###########################################################
- target: app_network_port
type: cloudify.vcloud.server_connected_to_port
- target: management_network_port
type: cloudify.vcloud.server_connected_to_port
mongod:
type: nodecellar.nodes.MongoDatabase
properties:
port: 27017
interfaces:
cloudify.interfaces.lifecycle:
###########################################################
# The MongoDBCollector depends on a python library called
# pymongo. We install this library in the 'configure'
# lifecycle hook of this node.
###########################################################
configure: scripts/mongo/install-pymongo.sh
###########################################################
# Notice that this node defines an additional collector
# to collect data on the MongoDB.
###########################################################
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
MongoDBCollector:
config:
hosts: localhost:27017
relationships:
- type: cloudify.relationships.contained_in
target: mongod_host
nodejs:
type: nodecellar.nodes.NodeJSServer
relationships:
- type: cloudify.relationships.contained_in
target: nodejs_host
nodecellar:
type: nodecellar.nodes.NodecellarApplicationModule
properties:
port: 8080
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
########################################
# Note: only ubuntu haproxy installation
# is supported.
########################################
haproxy:
type: haproxy.nodes.Proxy
properties:
###########################################################
# This is the port that will be used by haproxy.
###########################################################
frontend_port: 80
###########################################################
# This is the port that will be used by haproxy to display
# statistics.
###########################################################
statistics_port: 9000
backend_app_port: { get_property: [ nodecellar, port ] }
interfaces:
###########################################################
# Notice that this node defines an additional collector
# to collect data on the haproxy instance.
# Also notice that in the URL, port 9000 is used. If you
# choose to change this port on the haproxy node template,
# this URL should be updated as well.
###########################################################
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
HAProxyCollector:
config:
url: http://127.0.0.1:9000/haproxy_stats;csv
relationships:
- target: haproxy_frontend_host
type: cloudify.relationships.contained_in
###########################################################
# A floating ip to be attached to the haproxy frontend host,
# since eventually we want to be able to access the application
# from any machine, on any network.
###########################################################
frontend_floatingip:
type: cloudify.vcloud.nodes.FloatingIP
properties:
floatingip:
edge_gateway: { get_input: edge_gateway }
###########################################################
# 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: [ frontend_floatingip, public_ip ] }
port: { get_property: [haproxy, frontend_port] }