This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.tf
477 lines (420 loc) · 13.8 KB
/
main.tf
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# Terraform manifest for deployment of OpenStack Sunbeam
#
# Copyright (c) 2022 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
terraform {
required_providers {
juju = {
source = "juju/juju"
version = ">= 0.7.0"
}
}
}
provider "juju" {}
locals {
services-with-mysql = ["keystone", "glance", "nova", "horizon", "neutron", "placement", "cinder"]
}
data "juju_offer" "microceph" {
count = var.enable-ceph ? 1 : 0
url = var.ceph-offer-url
}
resource "juju_model" "sunbeam" {
name = var.model
cloud {
name = var.cloud
region = "localhost"
}
credential = var.credential
config = var.config
}
module "mysql" {
source = "./modules/mysql"
model = juju_model.sunbeam.name
name = "mysql"
channel = var.mysql-channel
scale = var.ha-scale
many-mysql = var.many-mysql
services = local.services-with-mysql
}
module "rabbitmq" {
source = "./modules/rabbitmq"
model = juju_model.sunbeam.name
scale = var.ha-scale
channel = var.rabbitmq-channel
}
module "glance" {
source = "./modules/openstack-api"
charm = "glance-k8s"
name = "glance"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["glance"]
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.enable-ceph ? var.os-api-scale : 1
mysql-router-channel = var.mysql-router-channel
resource-configs = {
ceph-osd-replication-count = var.ceph-osd-replication-count
enable-telemetry-notifications = var.enable-telemetry
}
}
module "keystone" {
source = "./modules/openstack-api"
charm = "keystone-k8s"
name = "keystone"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["keystone"]
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
resource-configs = {
enable-telemetry-notifications = var.enable-telemetry
}
}
module "nova" {
source = "./modules/openstack-api"
charm = "nova-k8s"
name = "nova"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["nova"]
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "horizon" {
source = "./modules/openstack-api"
charm = "horizon-k8s"
name = "horizon"
model = juju_model.sunbeam.name
channel = var.openstack-channel
mysql = module.mysql.name["horizon"]
keystone-credentials = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "neutron" {
source = "./modules/openstack-api"
charm = "neutron-k8s"
name = "neutron"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["neutron"]
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "placement" {
source = "./modules/openstack-api"
charm = "placement-k8s"
name = "placement"
model = juju_model.sunbeam.name
channel = var.openstack-channel
mysql = module.mysql.name["placement"]
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
resource "juju_application" "traefik" {
name = "traefik"
trust = true
model = juju_model.sunbeam.name
charm {
name = "traefik-k8s"
channel = "1.0/candidate"
series = "focal"
}
units = var.ingress-scale
}
resource "juju_application" "certificate-authority" {
name = "certificate-authority"
trust = true
model = juju_model.sunbeam.name
charm {
name = "tls-certificates-operator"
channel = "latest/stable"
series = "jammy"
}
config = {
generate-self-signed-certificates = true
ca-common-name = "internal-ca"
}
}
module "ovn" {
source = "./modules/ovn"
model = juju_model.sunbeam.name
channel = var.ovn-channel
scale = var.ha-scale
relay = true
relay-scale = var.os-api-scale
ca = juju_application.certificate-authority.name
}
# juju integrate ovn-central neutron
resource "juju_integration" "ovn-central-to-neutron" {
model = juju_model.sunbeam.name
application {
name = module.ovn.name
endpoint = "ovsdb-cms"
}
application {
name = module.neutron.name
endpoint = "ovsdb-cms"
}
}
# juju integrate neutron vault
resource "juju_integration" "neutron-to-ca" {
model = juju_model.sunbeam.name
application {
name = module.neutron.name
endpoint = "certificates"
}
application {
name = juju_application.certificate-authority.name
endpoint = "certificates"
}
}
# juju integrate nova placement
resource "juju_integration" "nova-to-placement" {
model = juju_model.sunbeam.name
application {
name = module.nova.name
endpoint = "placement"
}
application {
name = module.placement.name
endpoint = "placement"
}
}
# juju integrate glance microceph
resource "juju_integration" "glance-to-ceph" {
count = length(data.juju_offer.microceph)
model = juju_model.sunbeam.name
application {
name = module.glance.name
endpoint = "ceph"
}
application {
offer_url = data.juju_offer.microceph[count.index].url
}
}
module "cinder" {
source = "./modules/openstack-api"
charm = "cinder-k8s"
name = "cinder"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["cinder"]
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "cinder-ceph" {
source = "./modules/openstack-api"
charm = "cinder-ceph-k8s"
name = "cinder-ceph"
model = juju_model.sunbeam.name
channel = var.openstack-channel
rabbitmq = module.rabbitmq.name
mysql = module.mysql.name["cinder"]
ingress-internal = ""
ingress-public = ""
scale = var.ha-scale
resource-configs = {
ceph-osd-replication-count = var.ceph-osd-replication-count
enable-telemetry-notifications = var.enable-telemetry
}
mysql-router-channel = var.mysql-router-channel
}
# juju integrate cinder cinder-ceph
resource "juju_integration" "cinder-to-cinder-ceph" {
model = juju_model.sunbeam.name
application {
name = module.cinder.name
endpoint = "storage-backend"
}
application {
name = module.cinder-ceph.name
endpoint = "storage-backend"
}
}
# juju integrate cinder-ceph microceph
resource "juju_integration" "cinder-ceph-to-ceph" {
count = length(data.juju_offer.microceph)
model = juju_model.sunbeam.name
application {
name = module.cinder-ceph.name
endpoint = "ceph"
}
application {
offer_url = data.juju_offer.microceph[count.index].url
}
}
resource "juju_offer" "ca-offer" {
model = juju_model.sunbeam.name
application_name = juju_application.certificate-authority.name
endpoint = "certificates"
}
module "mysql-heat" {
count = var.enable-heat ? (var.many-mysql ? 1 : 0) : 0
source = "./modules/mysql"
model = juju_model.sunbeam.name
name = "mysql"
channel = var.mysql-channel
scale = var.ha-scale
many-mysql = var.many-mysql
services = ["heat"]
}
module "heat" {
count = var.enable-heat ? 1 : 0
source = "./modules/openstack-api"
charm = "heat-k8s"
name = "heat"
model = juju_model.sunbeam.name
channel = var.heat-channel
rabbitmq = module.rabbitmq.name
mysql = var.many-mysql ? module.mysql-heat[0].name["heat"] : "mysql"
keystone = module.keystone.name
keystone-ops = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "heat-cfn" {
count = var.enable-heat ? 1 : 0
source = "./modules/openstack-api"
charm = "heat-k8s"
name = "heat-cfn"
model = juju_model.sunbeam.name
channel = var.heat-channel
rabbitmq = module.rabbitmq.name
mysql = var.many-mysql ? module.mysql-heat[0].name["heat"] : "mysql"
keystone = module.keystone.name
keystone-ops = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
resource-configs = {
api_service = "heat-api-cfn"
}
}
module "mysql-telemetry" {
count = var.enable-telemetry ? (var.many-mysql ? 1 : 0) : 0
source = "./modules/mysql"
model = juju_model.sunbeam.name
name = "mysql"
channel = var.mysql-channel
scale = var.ha-scale
many-mysql = var.many-mysql
services = ["aodh", "gnocchi"]
}
module "aodh" {
count = var.enable-telemetry ? 1 : 0
source = "./modules/openstack-api"
charm = "aodh-k8s"
name = "aodh"
model = juju_model.sunbeam.name
channel = var.telemetry-channel
rabbitmq = module.rabbitmq.name
mysql = var.many-mysql ? module.mysql-telemetry[0].name["aodh"] : "mysql"
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
}
module "gnocchi" {
count = var.enable-telemetry ? 1 : 0
source = "./modules/openstack-api"
charm = "gnocchi-k8s"
name = "gnocchi"
model = juju_model.sunbeam.name
channel = var.telemetry-channel
mysql = var.many-mysql ? module.mysql-telemetry[0].name["gnocchi"] : "mysql"
keystone = module.keystone.name
ingress-internal = juju_application.traefik.name
ingress-public = juju_application.traefik.name
scale = var.os-api-scale
mysql-router-channel = var.mysql-router-channel
resource-configs = {
ceph-osd-replication-count = var.ceph-osd-replication-count
}
}
# juju integrate gnocchi microceph
resource "juju_integration" "gnocchi-to-ceph" {
count = var.enable-telemetry ? length(data.juju_offer.microceph) : 0
model = juju_model.sunbeam.name
application {
name = module.gnocchi[count.index].name
endpoint = "ceph"
}
application {
offer_url = data.juju_offer.microceph[count.index].url
}
}
resource "juju_application" "ceilometer" {
count = var.enable-telemetry ? 1 : 0
name = "ceilometer"
model = juju_model.sunbeam.name
charm {
name = "ceilometer-k8s"
channel = var.telemetry-channel
series = "jammy"
}
units = var.ha-scale
}
resource "juju_integration" "ceilometer-to-rabbitmq" {
count = var.enable-telemetry ? 1 : 0
model = juju_model.sunbeam.name
application {
name = juju_application.ceilometer[count.index].name
endpoint = "amqp"
}
application {
name = module.rabbitmq.name
endpoint = "amqp"
}
}
resource "juju_integration" "ceilometer-to-keystone" {
count = var.enable-telemetry ? 1 : 0
model = juju_model.sunbeam.name
application {
name = module.keystone.name
endpoint = "identity-credentials"
}
application {
name = juju_application.ceilometer[count.index].name
endpoint = "identity-credentials"
}
}