-
Notifications
You must be signed in to change notification settings - Fork 6
/
load_balancer.tf
executable file
·58 lines (51 loc) · 2.04 KB
/
load_balancer.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
resource "hcloud_load_balancer" "management_lb" {
name = "${var.cluster_name}-management-lb"
load_balancer_type = "lb11"
location = var.lb_location
labels = {
"rke2" = "management"
}
}
resource "hcloud_load_balancer_network" "management_lb_network_registration" {
load_balancer_id = hcloud_load_balancer.management_lb.id
subnet_id = hcloud_network_subnet.main.id
}
resource "hcloud_load_balancer_target" "management_lb_targets" {
count = var.master_node_count
type = "server"
load_balancer_id = hcloud_load_balancer.management_lb.id
server_id = hcloud_server.master[count.index].id
use_private_ip = true
depends_on = [
hcloud_load_balancer_network.management_lb_network_registration
]
}
resource "hcloud_load_balancer_service" "management_lb_k8s_service" {
load_balancer_id = hcloud_load_balancer.management_lb.id
protocol = "tcp"
listen_port = 6443
destination_port = 6443
depends_on = [hcloud_load_balancer_target.management_lb_targets, hcloud_server.worker]
}
resource "hcloud_load_balancer_service" "management_lb_ssh_service" {
load_balancer_id = hcloud_load_balancer.management_lb.id
protocol = "tcp"
listen_port = 22
destination_port = 22
depends_on = [hcloud_load_balancer_target.management_lb_targets]
}
resource "hcloud_load_balancer_service" "management_lb_register_service" {
load_balancer_id = hcloud_load_balancer.management_lb.id
protocol = "tcp"
listen_port = 9345
destination_port = 9345
depends_on = [hcloud_load_balancer_target.management_lb_targets]
}
resource "hcloud_load_balancer_service" "management_lb_service" {
for_each = toset(var.additional_lb_service_ports)
load_balancer_id = hcloud_load_balancer.management_lb.id
protocol = "tcp"
listen_port = tonumber(each.value)
destination_port = tonumber(each.value)
depends_on = [hcloud_load_balancer_target.management_lb_targets]
}