- Consul v1.9+
- Terraform v0.14+
- Consul Terraform Sync
Check out the AWS ALB Listener Rule Terraform module, which is use by Consul Terraform Sync configuration.
-
Go into
datacenter
and runterraform apply
. -
Go into
cloud
and runterraform apply
. -
Go into
datacenter
and update the variable forenable_peering = true
. Runterraform apply
to accept the peering connection from cloud. -
Set
kubectl
to the AWS EKS cluster in cloud.aws eks --region us-west-2 update-kubeconfig --name cloud
-
Change directory into
cloud-deployments
.cd cloud-deployments
-
Copy
credentials.example
tocredentials
.cp credentials.example credentials
-
In
credentials
, add the AWS role ARN and the Kubernetes context for EKS clusters. -
Deploy Consul Helm chart, ingress gateway configuration, and application to Kubernetes.
terraform apply -var-file=credentials
-
Change directory into
datacenter
.cd datacenter
-
Get the Terraform outputs, including the load balancer, target groups, and VPC ID. Copy the values, you will need them for
canary/datacenter.module.tfvars
.terraform output
-
Go into
canary
.cd canary
-
Copy
datacenter.module.tfvars.example
todatacenter.module.tfvars
.cp datacenter.module.tfvars.example datacenter.module.tfvars
-
Paste the Terraform outputs, including load balancer, target groups, and VPC ID.
-
Copy
credentials.example
tocredentials
.cp credentials.example credentials
-
In
credentials
, add the AWS secrets and role assumption information. -
Deploy Consul Terraform Sync to Kubernetes.
terraform apply -var-file=credentials
-
To verify everything is working, get the load balancer's DNS and issue an HTTP GET request with the
Host
header set tomy-application.my-company.net
.curl -H 'Host:my-application.my-company.net' my-application-1971614036.us-east-2.elb.amazonaws.com
-
In this demo, the "cloud" application is hosted on Kubernetes (for ease of deployment).
-
The ALB mimics a datacenter load balancer.
-
The configuration peers two VPCs in two different regions.
-
You would ideally configure your Kubernetes pod with an AWS IAM role for configuring a load balancer. To abstract away as many AWS constructs as possible, this demo passes the credentials to CTS directly to mimic the passing of any provider credentials.
-
Consul Terraform Sync is deployed to Kubernetes so that the daemon continuously runs. It uses a Docker image built by
canary/Dockerfile
.