-
Notifications
You must be signed in to change notification settings - Fork 0
/
lb-workers-vip.tf
65 lines (58 loc) · 1.77 KB
/
lb-workers-vip.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
resource "hcloud_load_balancer" "workers_lb" {
name = "workers_lb"
load_balancer_type = "lb11"
location = var.location
labels = {
type = "workers_lb"
}
algorithm {
type = "round_robin"
}
}
resource "hcloud_load_balancer_target" "load_balancer_worker_target" {
count = var.instances
type = "server"
load_balancer_id = hcloud_load_balancer.workers_lb.id
server_id = hcloud_server.kube-worker[count.index].id
}
resource "hcloud_load_balancer_service" "workers_service_1" {
load_balancer_id = hcloud_load_balancer.workers_lb.id
protocol = var.services_protocol
listen_port = var.services_workers_port_1
destination_port = var.services_workers_port_1
health_check {
protocol = var.services_protocol
port = var.services_workers_port_1
interval = "10"
timeout = "10"
http {
path = "/"
status_codes = ["2??", "3??"]
}
}
}
resource "hcloud_load_balancer_service" "workers_service_2" {
load_balancer_id = hcloud_load_balancer.workers_lb.id
protocol = var.services_protocol
listen_port = var.services_workers_port_2
destination_port = var.services_workers_port_2
health_check {
protocol = var.services_protocol
port = var.services_workers_port_2
interval = "10"
timeout = "10"
http {
path = "/"
status_codes = ["2??", "3??"]
}
}
}
resource "hcloud_load_balancer_network" "workers_network" {
load_balancer_id = hcloud_load_balancer.workers_lb.id
subnet_id = hcloud_network_subnet.hc_private_subnet.id
enable_public_interface = "true"
ip = var.lb_workers_private_ip
depends_on = [
hcloud_network_subnet.hc_private_subnet
]
}