-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.yaml
208 lines (176 loc) · 6.16 KB
/
base.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
heat_template_version: 2021-04-16
parameters:
flavor:
type: string
constraints:
- custom_constraint: nova.flavor
default: "t3.small"
image:
type: string
availability_zone:
type: string
class_c:
type: string
default: "16"
host_port:
type: number
description: Port used by hosts
default: 80
lb_port:
type: number
description: Outward-facing port for load balancer
default: 80
public_network:
type: string
description: Public network for external traffic
constraints:
- custom_constraint: neutron.network
default: "melbourne"
instance_count:
type: number
description: How many API instances to create
default: 2
lb_connection_limit:
type: number
default: 1500
api_branch:
type: string
description: Branch of traitecoevo/austraits_api to use for deployment
default: "master"
dns_zone:
type: string
default: "austraits.cloud.edu.au."
dns_name:
type: string
default: "api"
env_type:
type: string
constraints:
- allowed_values: ["dev", "prod"]
default: "dev"
logstash_image:
type: string
conditions:
is_dev: { equals: [ { get_param: env_type }, "dev" ]}
is_prod: { equals: [ { get_param: env_type }, "prod" ]}
resources:
network_stack:
type: OS::Heat::Stack
properties:
template: { get_file: network.yaml }
parameters:
class_c: { get_param: class_c }
public_network: { get_param: public_network }
logstash_stack:
type: OS::Heat::Stack
properties:
template: { get_file: logstash/base.yaml }
parameters:
image: { get_param: logstash_image }
availability_zone: { get_param: availability_zone }
subnet: { get_attr: [ network_stack, outputs, private_subnet ]}
host_secgroup: { get_resource: secgroup }
bucket_suffix: { list_join: ["-", [{ get_param: OS::stack_name }, { get_resource: random_string }] ]}
secgroup:
type: OS::Neutron::SecurityGroup
properties:
rules:
- remote_ip_prefix: { get_attr: [ network_stack, outputs, public_subnet_cidr ]}
port_range_min: { get_param: host_port }
port_range_max: { get_param: host_port }
protocol: tcp
lb:
type: OS::Octavia::LoadBalancer
properties:
availability_zone: { get_param: availability_zone }
vip_subnet: { get_attr: [ network_stack, outputs, public_subnet ]}
lb_listener:
type: OS::Octavia::Listener
properties:
loadbalancer: { get_resource: lb }
protocol: HTTP
protocol_port: { get_param: lb_port }
connection_limit: { get_param: lb_connection_limit }
lb_pool:
type: OS::Octavia::Pool
properties:
listener: { get_resource: lb_listener }
lb_algorithm: ROUND_ROBIN
protocol: HTTP
lb_monitor:
type: OS::Octavia::HealthMonitor
properties:
pool: { get_resource: lb_pool }
delay: 20
timeout: 10
max_retries: 1
type: HTTP
url_path: "/health-check"
http_method: HEAD
lb_public_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_network }
port_id: { get_attr: [lb, vip_port_id] }
wait_handle:
type: OS::Heat::WaitConditionHandle
wait_condition:
type: OS::Heat::WaitCondition
properties:
handle: { get_resource: wait_handle }
count: { get_param: instance_count } # wait for all instances to report success
timeout: 600
asg:
type: OS::Heat::AutoScalingGroup
properties:
min_size: { get_param: instance_count }
max_size: { get_param: instance_count }
desired_capacity: { get_param: instance_count }
resource:
type: server.yaml
properties:
flavor: { get_param: flavor }
image: { get_param: image }
availability_zone: { get_param: availability_zone }
subnet: { get_attr: [ network_stack, outputs, private_subnet ]}
secgroup: { get_resource: secgroup }
wc_notify: { get_attr: ["wait_handle", "curl_cli"] }
pool: { get_resource: lb_pool }
host_port: { get_param: host_port }
api_branch: { get_param: api_branch }
logstash_host: { get_attr: [ logstash_stack, outputs, logstash_host ]}
environment: { get_param: OS::stack_name }
lb_alarm:
type: OS::Aodh::LBMemberHealthAlarm
properties:
autoscaling_group_id: { get_resource: asg }
pool: { get_resource: lb_pool }
stack: { get_param: OS::stack_id }
alarm_actions:
- "trust+heat://"
repeat_actions: false
random_string:
type: OS::Heat::RandomString
properties:
length: 16
lb_dns_record:
type: OS::Designate::RecordSet
properties:
name: { if: [ is_dev, { list_join: [".", [{ get_resource: random_string }, "dev"]]}, { get_param: dns_name }] }
type: A
records:
- { get_attr: [ lb_public_ip, floating_ip_address ] }
zone: { get_param: dns_zone }
outputs:
lb_url:
description: "Public-facing URL for load balancer"
value:
str_replace:
template: http://$fqdn
params:
$fqdn: { get_attr: [ lb_dns_record, show, name ] }
lb_public_ip:
description: "Public-facing IP for load balancer"
value: { get_attr: [ lb_public_ip, floating_ip_address ] }
log_bucket:
value: { get_attr: [ logstash_stack, outputs, log_bucket ] }