-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
lb.tf
54 lines (46 loc) · 1.73 KB
/
lb.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
resource "oci_load_balancer_load_balancer" "k3s_load_balancer" {
lifecycle {
ignore_changes = [network_security_group_ids]
}
compartment_id = var.compartment_ocid
display_name = var.k3s_load_balancer_name
shape = var.public_lb_shape
subnet_ids = [oci_core_subnet.oci_core_subnet11.id]
freeform_tags = {
"provisioner" = "terraform"
"environment" = "${var.environment}"
"${var.unique_tag_key}" = "${var.unique_tag_value}"
}
ip_mode = "IPV4"
is_private = true
shape_details {
maximum_bandwidth_in_mbps = 10
minimum_bandwidth_in_mbps = 10
}
}
resource "oci_load_balancer_listener" "k3s_kube_api_listener" {
default_backend_set_name = oci_load_balancer_backend_set.k3s_kube_api_backend_set.name
load_balancer_id = oci_load_balancer_load_balancer.k3s_load_balancer.id
name = "K3s__kube_api_listener"
port = var.kube_api_port
protocol = "TCP"
}
resource "oci_load_balancer_backend_set" "k3s_kube_api_backend_set" {
health_checker {
protocol = "TCP"
port = var.kube_api_port
}
load_balancer_id = oci_load_balancer_load_balancer.k3s_load_balancer.id
name = "K3s__kube_api_backend_set"
policy = "ROUND_ROBIN"
}
resource "oci_load_balancer_backend" "k3s_kube_api_backend" {
depends_on = [
oci_core_instance_pool.k3s_servers,
]
count = var.k3s_server_pool_size
backendset_name = oci_load_balancer_backend_set.k3s_kube_api_backend_set.name
ip_address = data.oci_core_instance.k3s_servers_instances_ips[count.index].private_ip
load_balancer_id = oci_load_balancer_load_balancer.k3s_load_balancer.id
port = var.kube_api_port
}