-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathopenstack-haproxy-blueprint.yaml
315 lines (258 loc) · 10.1 KB
/
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
tosca_definitions_version: cloudify_dsl_1_4
description: >
This Blueprint installs the nodecellar application behind
an haproxy instance on an openstack cloud environment.
imports:
- http://www.getcloudify.org/spec/cloudify/7.1.0.dev1/types.yaml
- http://www.getcloudify.org/spec/diamond-plugin/1.3.17/plugin.yaml
- plugin:cloudify-openstack-plugin
- types/nodecellar.yaml
- types/openstack-types.yaml
- types/haproxy/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> <deployment_id> -i inputs.json
#####################################################################################
inputs:
image:
description: >
Image to be used when launching agent VM's
flavor:
description: >
Flavor of the agent VM's
agent_user:
description: >
User for connecting to agent VM's
network_name:
description: >
Openstack network name the new server will be connected to
floating_network_id:
description: >
The id of the network to use for allocating a floating ip
key_pair_name:
description: >
Openstack key pair name of the key to associate with the new server
private_key_path:
description: |
Path to the private key which will be used for connecting to the server
on the manager or machine running CLI if running in local mode.
number_of_instances:
description: |
The number of web server instances. Requests to the web servers will
be load balanced by the haproxy service.
type: integer
default: 2
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:
agent_config:
key: { get_property: [ keypair, private_key_path ] }
management_network_name: { get_input: network_name }
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
args:
security_groups: [{ get_attribute: [ mongod_security_group, external_name ]}]
relationships:
###########################################################
# Set the keypair for the VM
###########################################################
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
###########################################################
# Attaching the mongo security group to the mongo host
###########################################################
- target: mongod_security_group
type: cloudify.openstack.server_connected_to_security_group
nodejs_host:
type: nodecellar.nodes.MonitoredServer
properties:
agent_config:
key: { get_property: [ keypair, private_key_path ] }
management_network_name: { get_input: network_name }
###########################################################
# Setting the nodejs_host initial number of instances to 2.
# The default values for instances.deploy is 1.
###########################################################
capabilities:
scalable:
properties:
default_instances: { get_input: number_of_instances }
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
args:
security_groups: [{ get_attribute: [ nodecellar_security_group, external_name ]}]
relationships:
###########################################################
# Set the keypair for the VM
###########################################################
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
###########################################################
# Attaching the nodecellar security group to
# the nodecellar host
###########################################################
- target: nodecellar_security_group
type: cloudify.openstack.server_connected_to_security_group
haproxy_frontend_host:
type: nodecellar.nodes.MonitoredServer
properties:
agent_config:
key: { get_property: [ keypair, private_key_path ] }
management_network_name: { get_input: network_name }
interfaces:
cloudify.interfaces.lifecycle:
create:
inputs:
args:
security_groups: [{ get_attribute: [ haproxy_frontend_security_group, external_name ]}]
relationships:
###########################################################
# Set the keypair for the VM
###########################################################
- type: cloudify.openstack.server_connected_to_keypair
target: keypair
###########################################################
# Attaching an ip to the haproxy frontend host
###########################################################
- type: cloudify.openstack.server_connected_to_floating_ip
target: nodecellar_ip
###########################################################
# Attaching the haproxy frontend security group to
# the haproxy frontend host
###########################################################
- type: cloudify.openstack.server_connected_to_security_group
target: haproxy_frontend_security_group
###########################################################
# 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:
security_group:
name: mongod_security_group
rules:
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ mongod, port ] }
- remote_ip_prefix: 0.0.0.0/0
port: 28017
- remote_ip_prefix: 0.0.0.0/0
port: 22
###########################################################
# 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:
security_group:
name: nodecellar_security_group
rules:
- remote_ip_prefix: 0.0.0.0/0
port: { get_property: [ nodecellar, port ] }
- remote_ip_prefix: 0.0.0.0/0
port: 22
###########################################################
# 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:
security_group:
name: haproxy_frontend_security_group
rules:
- 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 ]}
- remote_ip_prefix: 0.0.0.0/0
port: 22
###########################################################
# 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:
floatingip:
floating_network_id: { get_input: floating_network_id }
###########################################################
# Key pair for connecting to the VMs using SSH.
# The key pair should exist in the OpenStack environment.
###########################################################
keypair:
type: cloudify.openstack.nodes.KeyPair
properties:
use_external_resource: true
resource_id: { get_input: key_pair_name }
private_key_path: { get_input: private_key_path }
###########################################################
# This outputs section exposes the application endpoint.
# You can access it by running:
# - cfy deployments outputs <deployment_id>
###########################################################
outputs:
endpoint:
description: Web application endpoint
value:
ip_address: { get_attribute: [ nodecellar_ip, floating_ip_address ] }
port: { get_property: [haproxy, frontend_port] }