-
Notifications
You must be signed in to change notification settings - Fork 6
/
spectro-cluster-edge-vsphere.tf
244 lines (217 loc) · 10.8 KB
/
spectro-cluster-edge-vsphere.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
resource "spectrocloud_cluster_edge_vsphere" "this" {
for_each = { for x in local.edge_vsphere_clusters : x.name => x }
name = each.value.name
context = try(each.value.context, "project")
tags = try(each.value.tags, [])
skip_completion = try(each.value.skip_completion, false)
edge_host_uid = each.value.edge_host_uid
cluster_meta_attribute = try(each.value.cluster_meta_attribute, "")
description = try(each.value.description, "")
cloud_config {
ssh_keys = concat(try(try(each.value.cloud_config.ssh_key, "") == "" ? try(each.value.cloud_config.ssh_keys, []) : [each.value.cloud_config.ssh_key], []), try(each.value.cloud_config.ssh_keys, []))
static_ip = each.value.cloud_config.static_ip
network_type = each.value.cloud_config.network_type
vip = each.value.cloud_config.vip
datacenter = each.value.cloud_config.datacenter
folder = each.value.cloud_config.folder
image_template_folder = can(each.value.cloud_config.image_template_folder) ? each.value.cloud_config.image_template_folder : null
network_search_domain = try(each.value.cloud_config.search_domain, "")
}
dynamic "cluster_rbac_binding" {
for_each = try(each.value.cluster_rbac_binding, [])
content {
type = cluster_rbac_binding.value.type
namespace = try(cluster_rbac_binding.value.namespace, "")
role = {
kind = cluster_rbac_binding.value.role.kind
name = cluster_rbac_binding.value.role.name
}
dynamic "subjects" {
for_each = try(cluster_rbac_binding.value.subjects, [])
content {
type = subjects.value.type
name = subjects.value.name
namespace = try(subjects.value.namespace, "")
}
}
}
}
dynamic "namespaces" {
for_each = try(each.value.namespaces, [])
content {
name = namespaces.value.name
resource_allocation = {
cpu_cores = try(namespaces.value.resource_allocation.cpu_cores, "")
memory_MiB = try(namespaces.value.resource_allocation.memory_MiB, "")
}
}
}
#infra profile
cluster_profile {
id = (local.profile_map[format("%s%%%s%%%s",
each.value.profiles.infra.name,
try(each.value.profiles.infra.version, "1.0.0"),
try(each.value.profiles.infra.context, "project"))].id)
dynamic "pack" {
for_each = try(each.value.profiles.infra.packs, [])
content {
name = pack.value.name
tag = try(pack.value.version, "")
registry_uid = try(local.all_registry_map[pack.value.registry][0], "")
type = (try(pack.value.is_manifest_pack, false)) ? "manifest" : "spectro"
values = "${(try(pack.value.is_manifest_pack, false)) ?
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)].values :
(pack.value.override_type == "values") ?
pack.value.values :
(pack.value.override_type == "params" ?
local.infra-pack-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)] :
local.infra-pack-template-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)])
}"
dynamic "manifest" {
for_each = try([local.infra_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)]], [])
content {
name = manifest.value.name
content = manifest.value.content
}
}
}
}
}
#system profile
cluster_profile {
id = (local.profile_map[format("%s%%%s%%%s",
each.value.profiles.system.name,
try(each.value.profiles.system.version, "1.0.0"),
try(each.value.profiles.system.context, "project"))].id)
dynamic "pack" {
for_each = try(each.value.profiles.system.packs, [])
content {
name = pack.value.name
tag = try(pack.value.version, "")
registry_uid = try(local.all_registry_map[pack.value.registry][0], "")
type = (try(pack.value.is_manifest_pack, false)) ? "manifest" : "spectro"
values = "${can(pack.value.override_type) ? (
(try(pack.value.is_manifest_pack, false)) ?
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", each.value.profiles.system.name, try(each.value.profiles.system.version, "1.0.0"), try(each.value.profiles.system.context, "project"), pack.value.name)].values :
(pack.value.override_type == "values") ?
pack.value.values :
(pack.value.override_type == "params" ?
local.system-pack-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.system.name, try(each.value.profiles.system.version, "1.0.0"), try(each.value.profiles.system.context, "project"), pack.value.name)] :
local.system-pack-template-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.system.name, try(each.value.profiles.system.version, "1.0.0"), try(each.value.profiles.system.context, "project"), pack.value.name)])) :
(pack.value.values)
}"
dynamic "manifest" {
for_each = "${can(local.system_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, try(each.value.profiles.system.version, "1.0.0"), try(each.value.profiles.system.context, "project"), pack.value.name)]) ?
local.system_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, try(each.value.profiles.system.version, "1.0.0"), try(each.value.profiles.system.context, "project"), pack.value.name)] :
(can(pack.value.manifests) ? pack.value.manifests : [])
}"
content {
name = manifest.value.name
content = "${can(pack.value.override_type) ? (
(pack.value.override_type == "values") ? manifest.value.content : "diff override type"
) : manifest.value.content
}"
}
}
}
}
}
# addon profiles
dynamic "cluster_profile" {
for_each = try(each.value.profiles.addons, [])
content {
id = (local.profile_map[format("%s%%%s%%%s",
cluster_profile.value.name,
try(cluster_profile.value.version, "1.0.0"),
try(cluster_profile.value.context, "project"))].id)
dynamic "pack" {
for_each = try(cluster_profile.value.packs, [])
content {
name = pack.value.name
tag = try(pack.value.version, "")
registry_uid = try(local.all_registry_map[pack.value.registry][0], "")
type = (try(pack.value.is_manifest_pack, false)) ? "manifest" : "spectro"
values = "${(try(pack.value.is_manifest_pack, false)) ?
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)].values :
(pack.value.override_type == "values") ?
pack.value.values :
(pack.value.override_type == "params" ?
local.addon_pack_params_replaced[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)] :
local.addon_pack_template_params_replaced[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)])
}"
dynamic "manifest" {
for_each = try(local.addon_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)], [])
content {
name = manifest.value.name
content = manifest.value.content
}
}
}
}
}
}
dynamic "machine_pool" {
for_each = each.value.node_groups
content {
name = machine_pool.value.name
control_plane = try(machine_pool.value.control_plane, false)
control_plane_as_worker = try(machine_pool.value.control_plane_as_worker, false)
count = machine_pool.value.count
node_repave_interval = can(machine_pool.value.node_repave_interval) ? machine_pool.value.node_repave_interval : null
update_strategy = try(machine_pool.value.update_strategy, "RollingUpdateScaleOut")
additional_labels = try(machine_pool.value.additional_labels, tomap({}))
dynamic "node" {
for_each = try(machine_pool.value.node, [])
content {
node_id = node.value.node_id
action = node.value.action
}
}
dynamic "taints" {
for_each = try(machine_pool.value.taints, [])
content {
key = taints.value.key
value = taints.value.value
effect = taints.value.effect
}
}
dynamic "placement" {
for_each = machine_pool.value.placements
content {
cluster = placement.value.cluster
resource_pool = placement.value.resource_pool
datastore = placement.value.datastore
network = placement.value.network
}
}
instance_type {
disk_size_gb = machine_pool.value.disk_size_gb
memory_mb = machine_pool.value.memory_mb
cpu = machine_pool.value.cpu
}
}
}
dynamic "backup_policy" {
for_each = try(tolist([each.value.backup_policy]), [])
content {
schedule = backup_policy.value.schedule
backup_location_id = local.bsl_map[backup_policy.value.backup_location]
prefix = backup_policy.value.prefix
expiry_in_hour = 7200
include_disks = true
include_cluster_resources = true
}
}
dynamic "scan_policy" {
for_each = try(tolist([each.value.scan_policy]), [])
content {
configuration_scan_schedule = scan_policy.value.configuration_scan_schedule
penetration_scan_schedule = scan_policy.value.penetration_scan_schedule
conformance_scan_schedule = scan_policy.value.conformance_scan_schedule
}
}
timeouts {
create = try(each.value.timeouts.create, "60m")
delete = try(each.value.timeouts.delete, "60m")
}
}