Search…
Creating an AWS Load Balancer
This guide shows you how to add an application load balancer in front of your Garden Enterprise Kubernetes Cluster in AWS. There are different ways to achieve this, this is a simple recommendation on how to get this done.
There are six steps to creating an application load balancer. These are outlined in the official AWS documentation as follows.
Step 2: Configure security settings for an HTTPS listener. You'll need to configure the availability zones so that your new load balancer is in the same VPC as your EKS cluster and in a public subnet.
Step 3: Configure a security group. Here you'll need to apply the security group that your EKS worker nodes are using. This is necessary for the load balancer to be able to forward traffic to the worker nodes. Furthermore you'll need to add a security group for port 80 and port 443 so that they are open to accepting connections through the public internet.
Step 4: Configure a target group. When configuring the health checks on the target groups in this step please choose the success codes 200 - 404. This is necessary because we also want the default backend which returns 404 to be recognized as healthy.
Configuring health checks on the target group
Step 5: Configure targets for the target group. Here you will need to select your worker nodes from your EKS cluster as the targets in the target group.
As an alternative to configuring the load balancer via AWS Console, you can also use terraform. This small snippet is an example on how to set up an application load balancer. Please keep in mind that you again need to pay attention to the security groups and health checks. You will need to replace all of the values starting with my- with your own.
Please also check the documentation on the application load balancer terraform module.
1
module "alb" {
2
source = "terraform-aws-modules/alb/aws"
3
version = "~> 5.0"
4
​
5
name = "garden-enterprise-lb"
6
​
7
load_balancer_type = "application"
8
​
9
vpc_id = "my-eks-vpc-id"
10
subnets = ["my-public-subnet"]
11
security_groups = ["my-http-and-https-secgroup", "my-eks-workernode-secgroup"]
12
​
13
target_groups = [
14
{
15
name_prefix = "default-"
16
backend_protocol = "HTTP"
17
backend_port = 80
18
target_type = "instance"
19
health_check = { matcher = "200-404" }
20
}
21
]
22
​
23
https_listeners = [
24
{
25
port = 443
26
protocol = "HTTPS"
27
certificate_arn = "my-certificate-resource"
28
target_group_index = 0
29
}
30
]
31
​
32
http_tcp_listeners = [
33
{
34
port = 80
35
protocol = "HTTP"
36
action_type = "redirect"
37
redirect = {
38
port = "443"
39
protocol = "HTTPS"
40
status_code = "HTTP_301"
41
}
42
}
43
]
44
​
45
tags = {
46
Environment = "Garden-LB"
47
}
48
}
Copied!
Last modified 7mo ago
Copy link