-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlb.tf
More file actions
177 lines (170 loc) · 5.16 KB
/
Copy pathlb.tf
File metadata and controls
177 lines (170 loc) · 5.16 KB
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
resource "stackit_public_ip" "lb_ip" {
project_id = var.stackit_project_id
lifecycle {
ignore_changes = [network_interface_id]
}
}
resource "stackit_loadbalancer" "cluster_lb" {
lifecycle {
ignore_changes = [options.acl]
}
project_id = var.stackit_project_id
name = "load-balancer-${var.cluster_id}"
target_pools = flatten([
var.bootstrap_count + var.master_count > 0 ? [
{
name = "master-target-pool-api"
target_port = 6443
targets = concat([
for index, ipv4 in module.master.ip_addresses : {
display_name = replace(module.master.node_names[index], ".", "-")
ip = ipv4
}
], [
for index, nic in stackit_network_interface.bootstrap_nic :
{
display_name = replace(stackit_server.bootstrap[0].name, ".", "-")
ip = nic.ipv4
}
])
active_health_check = {
healthy_threshold = 10
interval = "3s"
interval_jitter = "3s"
timeout = "3s"
unhealthy_threshold = 10
}
},
{
name = "master-target-pool-machineconfig"
target_port = 22623
targets = concat([
for index, ipv4 in module.master.ip_addresses : {
display_name = replace(module.master.node_names[index], ".", "-")
ip = ipv4
}
], [
for index, nic in stackit_network_interface.bootstrap_nic :
{
display_name = replace(stackit_server.bootstrap[0].name, ".", "-")
ip = nic.ipv4
}
])
active_health_check = {
healthy_threshold = 10
interval = "3s"
interval_jitter = "3s"
timeout = "3s"
unhealthy_threshold = 10
}
}] : [],
var.infra_count > 0 ? [
{
name = "infra-target-pool-http"
target_port = 80
targets = [
for index, ipv4 in module.infra.ip_addresses : {
display_name = replace(module.infra.node_names[index], ".", "-")
ip = ipv4
}
]
active_health_check = {
healthy_threshold = 10
interval = "3s"
interval_jitter = "3s"
timeout = "3s"
unhealthy_threshold = 10
}
},
{
name = "infra-target-pool-https"
target_port = 443
targets = [
for index, ipv4 in module.infra.ip_addresses : {
display_name = replace(module.infra.node_names[index], ".", "-")
ip = ipv4
}
]
active_health_check = {
healthy_threshold = 10
interval = "3s"
interval_jitter = "3s"
timeout = "3s"
unhealthy_threshold = 10
}
}] : []
])
listeners = flatten([
var.bootstrap_count + var.master_count > 0 ? [
{
display_name = "api"
port = 6443
protocol = "PROTOCOL_TCP"
target_pool = "master-target-pool-api"
},
{
display_name = "machineconfig"
port = 22623
protocol = "PROTOCOL_TCP"
target_pool = "master-target-pool-machineconfig"
}
] : [],
var.infra_count > 0 ? [
{
display_name = "ingress-http"
port = 80
protocol = var.lb_enable_proxy_protocol ? "PROTOCOL_TCP_PROXY" : "PROTOCOL_TCP"
target_pool = "infra-target-pool-http"
},
{
display_name = "ingress-https"
port = 443
protocol = var.lb_enable_proxy_protocol ? "PROTOCOL_TCP_PROXY" : "PROTOCOL_TCP"
target_pool = "infra-target-pool-https"
}
] : []
])
networks = [
{
network_id = local.subnet_uuid
role = "ROLE_LISTENERS_AND_TARGETS"
}
]
external_address = stackit_public_ip.lb_ip.ip
options = {
private_network_only = false
}
}
resource "stackit_dns_zone" "cluster_dns_zone" {
project_id = var.stackit_project_id
name = "${var.cluster_id} DNS zone"
dns_name = "${var.cluster_id}.${var.base_domain}"
}
resource "stackit_dns_record_set" "api" {
project_id = var.stackit_project_id
zone_id = stackit_dns_zone.cluster_dns_zone.zone_id
name = "api"
type = "A"
records = [stackit_public_ip.lb_ip.ip]
}
resource "stackit_dns_record_set" "api-int" {
project_id = var.stackit_project_id
zone_id = stackit_dns_zone.cluster_dns_zone.zone_id
name = "api-int"
type = "A"
records = [stackit_public_ip.lb_ip.ip]
}
resource "stackit_dns_record_set" "ingress" {
project_id = var.stackit_project_id
zone_id = stackit_dns_zone.cluster_dns_zone.zone_id
name = "ingress"
type = "A"
records = [stackit_public_ip.lb_ip.ip]
}
resource "stackit_dns_record_set" "apps" {
project_id = var.stackit_project_id
zone_id = stackit_dns_zone.cluster_dns_zone.zone_id
name = "*.apps"
type = "CNAME"
records = ["ingress.${var.cluster_id}.${var.base_domain}."]
}