forked from tibordp/terraform-hcloud-dualstack-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadbalancer.tf
25 lines (22 loc) · 841 Bytes
/
loadbalancer.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
locals {
use_load_balancer = var.control_plane_lb_type != ""
}
resource "hcloud_load_balancer" "control_plane" {
count = local.use_load_balancer ? 1 : 0
name = "${var.name}-control-plane"
load_balancer_type = var.control_plane_lb_type
location = var.location
}
resource "hcloud_load_balancer_service" "control_plane" {
count = local.use_load_balancer ? 1 : 0
load_balancer_id = hcloud_load_balancer.control_plane[0].id
listen_port = 6443
destination_port = 6443
protocol = "tcp"
}
resource "hcloud_load_balancer_target" "control_plane_target" {
count = local.use_load_balancer ? var.master_count : 0
type = "server"
load_balancer_id = hcloud_load_balancer.control_plane[0].id
server_id = module.master[count.index].id
}