forked from kube-hetzner/terraform-hcloud-kube-hetzner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
placement_groups.tf
67 lines (63 loc) · 1.89 KB
/
placement_groups.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
locals {
control_plane_placement_compat_groups = max(
0,
[
for cp_pool in var.control_plane_nodepools :
cp_pool.placement_group_compat_idx + 1 if cp_pool.placement_group_compat_idx != null && cp_pool.placement_group == null
]...
)
control_plane_groups = toset(
[
for cp_pool in var.control_plane_nodepools :
cp_pool.placement_group if cp_pool.placement_group != null
]
)
agent_placement_compat_groups = max(
0,
[
for ag_pool in var.agent_nodepools :
ag_pool.placement_group_compat_idx + 1 if ag_pool.placement_group_compat_idx != null && ag_pool.placement_group == null
]...
)
agent_placement_groups = toset(
concat(
[
for ag_pool in var.agent_nodepools :
ag_pool.placement_group if ag_pool.placement_group != null
],
concat(
[
for ag_pool in var.agent_nodepools :
[
for node, node_config in coalesce(ag_pool.nodes, {}) :
node_config.placement_group if node_config.placement_group != null
]
]
)...
)
)
}
resource "hcloud_placement_group" "control_plane" {
count = local.control_plane_placement_compat_groups
name = "${var.cluster_name}-control-plane-${count.index + 1}"
labels = local.labels
type = "spread"
}
resource "hcloud_placement_group" "control_plane_named" {
for_each = local.control_plane_groups
name = "${var.cluster_name}-control-plane-${each.key}"
labels = local.labels
type = "spread"
}
resource "hcloud_placement_group" "agent" {
count = local.control_plane_placement_compat_groups
name = "${var.cluster_name}-agent-${count.index + 1}"
labels = local.labels
type = "spread"
}
resource "hcloud_placement_group" "agent_named" {
for_each = local.agent_placement_groups
name = "${var.cluster_name}-agent-${each.key}"
labels = local.labels
type = "spread"
}