-
Notifications
You must be signed in to change notification settings - Fork 5
/
load-balancing.tf
114 lines (104 loc) · 3.75 KB
/
load-balancing.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
resource "aws_elb" "aws_rke2_elb" {
connection_draining = false
connection_draining_timeout = 300
cross_zone_load_balancing = true
desync_mitigation_mode = "defensive"
idle_timeout = 60
internal = false
name = "${var.prefix}-k8s-lb"
security_groups = [aws_security_group.aws_rke2_sg.id]
subnets = [aws_subnet.aws_rke2_public_subnet1.id, aws_subnet.aws_rke2_public_subnet2.id, aws_subnet.aws_rke2_public_subnet3.id]
depends_on = [aws_instance.aws_ec2_instance_control, aws_instance.aws_ec2_instance_controls]
health_check {
healthy_threshold = 3
interval = 30
target = "TCP:6443"
timeout = 5
unhealthy_threshold = 5
}
listener {
instance_port = 6443
instance_protocol = "tcp"
lb_port = 6443
lb_protocol = "tcp"
}
listener {
instance_port = 9345
instance_protocol = "tcp"
lb_port = 9345
lb_protocol = "tcp"
}
listener {
instance_port = 80
instance_protocol = "tcp"
lb_port = 80
lb_protocol = "tcp"
}
listener {
instance_port = 443
instance_protocol = "tcp"
lb_port = 443
lb_protocol = "tcp"
}
}
resource "aws_elb_attachment" "aws_rke2_elb_attachment1" {
elb = aws_elb.aws_rke2_elb.id
count = var.number_of_instances_control
instance = aws_instance.aws_ec2_instance_control[count.index].id
depends_on = [aws_elb.aws_rke2_elb]
}
resource "aws_elb_attachment" "aws_rke2_elb_attachment2" {
elb = aws_elb.aws_rke2_elb.id
count = var.number_of_instances_controls
instance = aws_instance.aws_ec2_instance_controls[count.index].id
depends_on = [aws_elb.aws_rke2_elb]
}
resource "aws_elb" "aws_rke2_ingress_elb" {
connection_draining = false
connection_draining_timeout = 300
cross_zone_load_balancing = true
desync_mitigation_mode = "defensive"
idle_timeout = 60
internal = false
name = "${var.prefix}-ingress-lb"
security_groups = [aws_security_group.aws_rke2_sg.id]
subnets = [aws_subnet.aws_rke2_public_subnet1.id, aws_subnet.aws_rke2_public_subnet2.id, aws_subnet.aws_rke2_public_subnet3.id]
depends_on = [aws_instance.aws_ec2_instance_control, aws_instance.aws_ec2_instance_controls, aws_instance.aws_ec2_instance_worker]
health_check {
healthy_threshold = 3
interval = 30
target = "TCP:80"
timeout = 5
unhealthy_threshold = 5
}
listener {
instance_port = 80
instance_protocol = "tcp"
lb_port = 80
lb_protocol = "tcp"
}
listener {
instance_port = 443
instance_protocol = "tcp"
lb_port = 443
lb_protocol = "tcp"
}
}
resource "aws_elb_attachment" "aws_rke2_ingress_elb_attachment1" {
elb = aws_elb.aws_rke2_ingress_elb.id
count = var.number_of_instances_control
instance = aws_instance.aws_ec2_instance_control[count.index].id
depends_on = [aws_elb.aws_rke2_ingress_elb]
}
resource "aws_elb_attachment" "aws_rke2_ingress_elb_attachment2" {
elb = aws_elb.aws_rke2_ingress_elb.id
count = var.number_of_instances_controls
instance = aws_instance.aws_ec2_instance_controls[count.index].id
depends_on = [aws_elb.aws_rke2_ingress_elb]
}
resource "aws_elb_attachment" "aws_rke2_ingress_elb_attachment3" {
elb = aws_elb.aws_rke2_ingress_elb.id
count = var.number_of_instances_worker
instance = aws_instance.aws_ec2_instance_worker[count.index].id
depends_on = [aws_elb.aws_rke2_ingress_elb]
}