-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_balancer.tf
56 lines (45 loc) · 1.65 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
resource "openstack_lb_loadbalancer_v2" "k3s_master" {
count = var.k3s_master_load_balancer ? 1 : 0
name = "${var.cluster_name}-master"
vip_subnet_id = var.cluster_subnet_id
}
resource "openstack_lb_pool_v2" "k3s_master" {
count = var.k3s_master_load_balancer ? 1 : 0
name = "k3s-master"
protocol = "HTTPS"
lb_method = "LEAST_CONNECTIONS"
loadbalancer_id = openstack_lb_loadbalancer_v2.k3s_master.0.id
}
resource "openstack_lb_listener_v2" "k3s_master" {
count = var.k3s_master_load_balancer ? 1 : 0
name = "k3s-master"
protocol = "HTTPS"
protocol_port = 443
default_pool_id = openstack_lb_pool_v2.k3s_master.0.id
loadbalancer_id = openstack_lb_loadbalancer_v2.k3s_master.0.id
}
resource "openstack_lb_monitor_v2" "k3s_master" {
count = var.k3s_master_load_balancer ? 1 : 0
name = "k3s-master"
pool_id = openstack_lb_pool_v2.k3s_master.0.id
type = "TCP"
delay = 5
timeout = 3
max_retries = 3
}
resource "openstack_lb_member_v2" "k3s_master1" {
count = var.k3s_master_load_balancer ? 1 : 0
name = "${var.cluster_name}-server1"
pool_id = openstack_lb_pool_v2.k3s_master.0.id
subnet_id = var.cluster_subnet_id
address = module.server1.node_ip
protocol_port = 6443
}
resource "openstack_lb_member_v2" "k3s_masters" {
count = var.k3s_master_load_balancer ? length(module.servers) : 0
name = "${var.cluster_name}-server${count.index + 2}"
pool_id = openstack_lb_pool_v2.k3s_master.0.id
subnet_id = var.cluster_subnet_id
address = module.servers[count.index].node_ip
protocol_port = 6443
}