Skip to content

Commit 72f204f

Browse files
committed
Implement K8s API LB using cloudscale.ch LB
1 parent 03fbe2e commit 72f204f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

lb.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,39 @@ module "lb" {
1919
internal_vip = cidrhost(var.privnet_cidr, 100)
2020
enable_proxy_protocol = var.lb_enable_proxy_protocol
2121
}
22+
23+
resource "cloudscale_load_balancer" "api" {
24+
name = "${var.cluster_id}_api"
25+
flavor_slug = "lb-standard"
26+
zone_slug = "${var.region}1"
27+
}
28+
29+
resource "cloudscale_load_balancer_pool" "api" {
30+
name = "${var.cluster_id}_api"
31+
algorithm = "round_robin"
32+
protocol = "tcp"
33+
load_balancer_uuid = cloudscale_load_balancer.api.id
34+
}
35+
36+
resource "cloudscale_load_balancer_listener" "api_k8s" {
37+
name = "${var.cluster_id}_api-k8s"
38+
pool_uuid = cloudscale_load_balancer_pool.api.id
39+
protocol = "tcp"
40+
protocol_port = 6443
41+
}
42+
43+
resource "cloudscale_load_balancer_pool_member" "api" {
44+
count = length(module.master.ip_addresses)
45+
name = "${var.cluster_id}_api-member-${count.index}"
46+
pool_uuid = cloudscale_load_balancer_pool.api.id
47+
protocol_port = 6443
48+
address = module.master.ip_addresses[count.index]
49+
subnet_uuid = local.subnet_uuid
50+
}
51+
52+
resource "cloudscale_load_balancer_health_monitor" "api" {
53+
pool_uuid = cloudscale_load_balancer_pool.api.id
54+
type = "https"
55+
http_url_path = "/readyz"
56+
http_host = "api.${var.cluster_id}.${var.base_domain}"
57+
}

0 commit comments

Comments
 (0)