infrastructure/infrastructure/lb.tf

79 lines
1.7 KiB
HCL

resource "hcloud_load_balancer" "k8s_lb" {
name = "k8s-lb"
load_balancer_type = "lb11"
location = "hel1"
}
resource "hcloud_load_balancer_network" "k8s_lb_net" {
load_balancer_id = hcloud_load_balancer.k8s_lb.id
network_id = hcloud_network.k8s_net.id
ip = "172.23.2.5"
}
resource "hcloud_load_balancer_target" "k8s_lb_target" {
type = "label_selector"
label_selector = "node_type=worker"
load_balancer_id = hcloud_load_balancer.k8s_lb.id
use_private_ip = true
}
resource "hcloud_managed_certificate" "icb4dc0de_20230613_001" {
name = "icb4dc0de_20230613_001"
domain_names = [
"icb4dc0.de",
"*.icb4dc0.de",
"*.inetmock.icb4dc0.de",
"*.buildr.icb4dc0.de",
"*.prskr.icb4dc0.de",
"*.fider.icb4dc0.de",
"*.ide.icb4dc0.de",
]
labels = {
}
}
resource "hcloud_load_balancer_service" "k8s_lb_svc_https" {
load_balancer_id = hcloud_load_balancer.k8s_lb.id
protocol = "https"
destination_port = 32080
health_check {
protocol = "tcp"
port = 32080
interval = 5
timeout = 3
retries = 3
http {
domain = "code.icb4dc0.de"
path = "/"
tls = false
status_codes = [
"2??",
"3??"
]
}
}
http {
redirect_http = true
certificates = [
hcloud_managed_certificate.icb4dc0de_20230613_001.id
]
}
}
resource "hcloud_load_balancer_service" "k8s_lb_svc_ssh" {
load_balancer_id = hcloud_load_balancer.k8s_lb.id
protocol = "tcp"
destination_port = 32022
listen_port = 22
health_check {
protocol = "tcp"
port = 32022
interval = 5
timeout = 3
retries = 3
}
}