Illumina Innovates with Rancher and Kubernetes
This how-to guide describes how to set up a load balancer in Amazon’s EC2 service that will direct traffic to multiple instances on EC2.
Note: Rancher only supports using the Amazon NLB when terminating traffic in tcp mode for port 443 rather than tls mode. This is due to the fact that the NLB does not inject the correct headers into requests when terminated at the NLB. This means that if you want to use certificates managed by the Amazon Certificate Manager (ACM), you should use an ELB or ALB.
tcp
tls
Configuring an Amazon NLB is a multistage process:
Prerequisite: These instructions assume you have already created Linux instances in EC2. The load balancer will direct traffic to these two nodes.
Begin by creating two target groups for the TCP protocol, one with TCP port 443 and one regarding TCP port 80 (providing redirect to TCP port 443). You’ll add your Linux nodes to these groups.
Your first NLB configuration step is to create two target groups. Technically, only port 443 is needed to access Rancher, but its convenient to add a listener for port 80 which will be redirected to port 443 automatically. The NGINX ingress controller on the nodes will make sure that port 80 gets redirected to port 443.
Configure the first target group according to the table below. Screenshots of the configuration are shown just below the table.
rancher-tcp-443
TCP
443
instance
HTTP
/healthz
override
80
3
6 seconds
10 second
200-399
Click Create target group to create the second target group, regarding TCP port 80.
Configure the second target group according to the table below. Screenshots of the configuration are shown just below the table.
rancher-tcp-80
traffic port
Next, add your Linux nodes to both target groups.
Select the target group named rancher-tcp-443, click the tab Targets and choose Edit.
Select the instances (Linux nodes) you want to add, and click Add to registered.
Screenshot Add targets to target group TCP port 443
Screenshot Added targets to target group TCP port 443
When the instances are added, click Save on the bottom right of the screen.
Repeat those steps, replacing rancher-tcp-443 with rancher-tcp-80. The same instances need to be added as targets to this target group.
Use Amazon’s Wizard to create an Network Load Balancer. As part of this process, you’ll add the target groups you created in 1. Create Target Groups.
Use Amazon’s Wizard to create an Network Load Balancer. As part of this process, you’ll add the target groups you created in Create Target Groups.
From your web browser, navigate to the Amazon EC2 Console.
From the navigation pane, choose LOAD BALANCING > Load Balancers.
Click Create Load Balancer.
Choose Network Load Balancer and click Create. Then complete each form.
Set the following fields in the form:
rancher
internal
internet-facing
10 seconds
Since you registered your targets earlier, all you have to do is click Next: Review.
Look over the load balancer details and click Create when you’re satisfied.
After AWS creates the NLB, click Close.
Select your newly created NLB and select the Listeners tab.
Click Add listener.
Use TCP:80 as Protocol : Port
Click Add action and choose Forward to…
From the Forward to drop-down, choose rancher-tcp-80.
Click Save in the top right of the screen.