2017-11-08 06:56:50 +01:00
|
|
|
# Network Load Balancer for Ingress
|
|
|
|
resource "aws_lb" "ingress" {
|
|
|
|
name = "${var.cluster_name}-ingress"
|
|
|
|
load_balancer_type = "network"
|
|
|
|
internal = false
|
|
|
|
|
|
|
|
subnets = ["${aws_subnet.public.*.id}"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Forward HTTP traffic to instances
|
|
|
|
resource "aws_lb_listener" "ingress-http" {
|
|
|
|
load_balancer_arn = "${aws_lb.ingress.arn}"
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 80
|
|
|
|
|
|
|
|
default_action {
|
|
|
|
type = "forward"
|
|
|
|
target_group_arn = "${aws_lb_target_group.workers-http.arn}"
|
2017-09-18 06:40:33 +02:00
|
|
|
}
|
2017-11-08 06:56:50 +01:00
|
|
|
}
|
2017-09-18 06:40:33 +02:00
|
|
|
|
2017-11-08 06:56:50 +01:00
|
|
|
# Forward HTTPS traffic to instances
|
|
|
|
resource "aws_lb_listener" "ingress-https" {
|
|
|
|
load_balancer_arn = "${aws_lb.ingress.arn}"
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 443
|
|
|
|
|
|
|
|
default_action {
|
|
|
|
type = "forward"
|
|
|
|
target_group_arn = "${aws_lb_target_group.workers-https.arn}"
|
2017-09-18 06:40:33 +02:00
|
|
|
}
|
2017-11-08 06:56:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Network Load Balancer target groups of instances
|
|
|
|
|
|
|
|
resource "aws_lb_target_group" "workers-http" {
|
|
|
|
name = "${var.cluster_name}-workers-http"
|
|
|
|
vpc_id = "${aws_vpc.network.id}"
|
|
|
|
target_type = "instance"
|
|
|
|
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 80
|
2017-09-18 06:40:33 +02:00
|
|
|
|
2017-09-28 09:46:17 +02:00
|
|
|
# Ingress Controller HTTP health check
|
2017-09-18 06:40:33 +02:00
|
|
|
health_check {
|
2017-11-08 06:56:50 +01:00
|
|
|
protocol = "HTTP"
|
|
|
|
port = 10254
|
|
|
|
path = "/healthz"
|
|
|
|
|
|
|
|
# NLBs required to use same healthy and unhealthy thresholds
|
|
|
|
healthy_threshold = 3
|
|
|
|
unhealthy_threshold = 3
|
|
|
|
|
|
|
|
# Interval between health checks required to be 10 or 30
|
|
|
|
interval = 10
|
2017-09-18 06:40:33 +02:00
|
|
|
}
|
2017-11-08 06:56:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_lb_target_group" "workers-https" {
|
|
|
|
name = "${var.cluster_name}-workers-https"
|
|
|
|
vpc_id = "${aws_vpc.network.id}"
|
|
|
|
target_type = "instance"
|
|
|
|
|
|
|
|
protocol = "TCP"
|
|
|
|
port = 443
|
2017-09-18 06:40:33 +02:00
|
|
|
|
2017-11-08 06:56:50 +01:00
|
|
|
# Ingress Controller HTTP health check
|
|
|
|
health_check {
|
|
|
|
protocol = "HTTP"
|
|
|
|
port = 10254
|
|
|
|
path = "/healthz"
|
|
|
|
|
|
|
|
# NLBs required to use same healthy and unhealthy thresholds
|
|
|
|
healthy_threshold = 3
|
|
|
|
unhealthy_threshold = 3
|
|
|
|
|
|
|
|
# Interval between health checks required to be 10 or 30
|
|
|
|
interval = 10
|
|
|
|
}
|
2017-09-18 06:40:33 +02:00
|
|
|
}
|