-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch Ingress ELB to a network load balancer
* Require terraform-provider-aws 1.7 or higher
- Loading branch information
Showing
4 changed files
with
91 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,80 @@ | ||
# Ingress Network Load Balancer | ||
resource "aws_elb" "ingress" { | ||
name = "${var.cluster_name}-ingress" | ||
subnets = ["${aws_subnet.public.*.id}"] | ||
security_groups = ["${aws_security_group.worker.id}"] | ||
|
||
listener { | ||
lb_port = 80 | ||
lb_protocol = "tcp" | ||
instance_port = 80 | ||
instance_protocol = "tcp" | ||
# 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}" | ||
} | ||
} | ||
|
||
listener { | ||
lb_port = 443 | ||
lb_protocol = "tcp" | ||
instance_port = 443 | ||
instance_protocol = "tcp" | ||
# 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}" | ||
} | ||
} | ||
|
||
# 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 | ||
|
||
# Ingress Controller HTTP health check | ||
health_check { | ||
target = "HTTP:10254/healthz" | ||
healthy_threshold = 2 | ||
unhealthy_threshold = 4 | ||
timeout = 5 | ||
interval = 6 | ||
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 | ||
} | ||
} | ||
|
||
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 | ||
|
||
connection_draining = true | ||
connection_draining_timeout = 300 | ||
# 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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
output "ingress_dns_name" { | ||
value = "${aws_elb.ingress.dns_name}" | ||
description = "DNS name of the ELB for distributing traffic to Ingress controllers" | ||
value = "${aws_lb.ingress.dns_name}" | ||
description = "DNS name of the network load balancer for distributing traffic to Ingress controllers" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ terraform { | |
} | ||
|
||
provider "aws" { | ||
version = "~> 1.0" | ||
version = "~> 1.7" | ||
} | ||
|
||
provider "local" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters