-
Notifications
You must be signed in to change notification settings - Fork 12
/
lbaas_with_server_resource_group.yaml
177 lines (150 loc) · 5.38 KB
/
lbaas_with_server_resource_group.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
heat_template_version: 2021-04-16
description: >
Fully featured template to launch a private network, setup some web servers
joined to the network and then provision a Neutron load balancer with some
pool members to balance between them. We also include a wait signal to
ensure the Apache installation has completed before returning stack build
success.
parameters:
flavor:
type: string
description: Flavor used for servers
default: t3.xsmall
constraints:
- custom_constraint: nova.flavor
image:
type: string
description: Image used for servers
default: NeCTAR Ubuntu 22.04 LTS (Jammy) amd64
availability_zone:
type: string
description: Availability Zone
backend_port:
type: number
default: 80
description: Port used by the servers
lb_port:
type: number
default: 80
description: Port used by the load balancer
public_network:
type: string
description: Network used by the load balancer
constraints:
- custom_constraint: neutron.network
count:
type: number
description: Number of servers to launch
default: 2
resources:
network:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::Net
type: OS::Neutron::Net
subnet:
type: OS::Neutron::Subnet
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::Subnet
properties:
dns_nameservers:
- 1.1.1.1
- 1.0.0.1
network: { get_resource: network }
ip_version: 4
cidr: 192.168.13.0/24
allocation_pools:
- { start: 192.168.13.100, end: 192.168.13.199 }
router:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::Router
type: OS::Neutron::Router
properties:
external_gateway_info: {"network": { get_param: public_network }}
router_gateway:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::RouterGateway
type: OS::Neutron::RouterGateway
properties:
router_id: { get_resource: router }
network_id: { get_param: public_network }
router_interface:
#$ https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::RouterInterface
type: OS::Neutron::RouterInterface
properties:
router: { get_resource: router }
subnet: { get_resource: subnet }
secgroup:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron::SecurityGroup
type: OS::Neutron::SecurityGroup
properties:
rules:
- remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: { get_param: backend_port }
port_range_max: { get_param: backend_port }
wait_handle:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::WaitConditionHandle
type: OS::Heat::WaitConditionHandle
wait_condition:
type: OS::Heat::WaitCondition
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::WaitCondition
properties:
handle: { get_resource: wait_handle }
count: { get_param: count } # Wait for all servers to report success
timeout: 600
group:
type: OS::Heat::ResourceGroup
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::ResourceGroup
properties:
count: { get_param: count }
resource_def:
type: lbaas_server_member.yaml
properties:
image: { get_param: image }
flavor: { get_param: flavor }
availability_zone: { get_param: availability_zone }
secgroup: { get_resource: secgroup }
network: { get_resource: network }
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
pool: { get_resource: pool }
backend_port: { get_param: backend_port }
subnet: { get_resource: subnet }
loadbalancer:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Octavia::LoadBalancer
type: OS::Octavia::LoadBalancer
properties:
vip_subnet: { get_resource: subnet }
listener:
type: OS::Octavia::Listener
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Octavia::Listener
properties:
loadbalancer: { get_resource: loadbalancer }
protocol: HTTP
protocol_port: 80
pool:
type: OS::Octavia::Pool
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Octavia::Pool
properties:
listener: { get_resource: listener }
lb_algorithm: ROUND_ROBIN
protocol: HTTP
monitor:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Octavia::HealthMonitor
type: OS::Octavia::HealthMonitor
properties:
type: TCP
delay: 3
timeout: 3
max_retries: 3
pool: { get_resource: pool }
floating_ip:
# https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Neutron:FloatingIP
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_network }
port_id: { get_attr: [loadbalancer, vip_port_id] }
outputs:
lb_url:
description: This URL is the external URL that can be used to access the load balancer.
value:
str_replace:
template: http://__ipaddress__:__port__
params:
__ipaddress__: { get_attr: [ floating_ip, floating_ip_address ] }
__port__: { get_param: lb_port }