-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathspectro-cluster-edge-native.tf
190 lines (166 loc) · 7.58 KB
/
spectro-cluster-edge-native.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
resource "spectrocloud_cluster_edge_native" "this" {
for_each = { for x in local.edge_native_clusters : x.name => x }
name = each.value.name
context = try(each.value.context, "project")
apply_setting = try(each.value.apply_setting, "DownloadAndInstall")
tags = try(each.value.tags, [])
skip_completion = try(each.value.skip_completion, false)
cluster_meta_attribute = try(each.value.cluster_meta_attribute, "")
description = try(each.value.description, "")
cloud_config {
ssh_keys = try(each.value.cloud_config.ssh_keys, "")
vip = try(each.value.cloud_config.vip, "")
ntp_servers = try(each.value.cloud_config.ntp_servers, [])
overlay_cidr_range = try(each.value.cloud_config.overlay_cidr_range, "")
}
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
}
}
}
}
}
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)
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 "edge_host" {
for_each = try(machine_pool.value.edge_hosts, [])
content {
host_uid = edge_host.value.host_uid
static_ip = try(edge_host.value.static_ip,"")
}
}
// old plain list.
#host_uids = machine_pool.value.host_uids
dynamic "taints" {
for_each = try(machine_pool.value.taints, [])
content {
key = taints.value.key
value = taints.value.value
effect = taints.value.effect
}
}
}
}
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")
}
}