Skip to content

2stacks/terraform-nginx-lb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nginx Loadbalancer for Rancher Kubernetes

Use Terraform to deploy a Nginx Loadbalancer for a Rancher Kubernetes Cluster.

Summary

This is not a Kubernetes Ingress. This project's goal is to provide an alternative to a hardware loadbalancer such as an F5 for load balancing Kubernetes worker nodes. More specifically this project allows you to host a public Kubernetes cluster behind a NAT boundary using server names and SSL SNI. The current Nginx configuration has been customized for running a three node Rancher Kubernetes cluster however it can be modified to load balance any Kubernetes Cluster.

Note: This project is customized for KVM servers running Openvswitch. Installation of these dependencies can be complex and is outside the scope of this project.

Prereqs

KVM Server running Openvswitch

Terraform and the terraform-provider-libvirt

Setup

Clone Repository

git clone https://github.com/2stacks/terraform-nginx-lb.git
cd terraform-nginx-lb

Create secrets variable file, add your SSH public key and update database passwords.

cp secret.auto.tfvars.example secret.auto.tfvars

Deploy libvirt guest with Terraform

terraform init
terraform plan
terraform apply

When Terraform finishes it will output the libvirt guest IP

Example:

Outputs:

ip = [
    [
        192.168.100.15,
        fe80::5054:ff:fec2:43bd
    ]
]

If running this load balancer behind a NAT boundary you should set up port forwarding for TCP 80 and 443 to the IP given in the Terraform Output.

Important Variables

Variable Name Usage
domain_name Sets the domian name of the Rancher server and Kubernetes worker nodes to be loadbalanced
nameserver Name server the loadbalancer should use to resolve the Rancher server and node names

TODO

  • Use jinja2 to produce the nginx.conf

About

Kubernetes Cluster Loadbalancer with NGINX and Terraform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published