Deploy Consul on AWS EKS using Terraform and Helm

Prerequisites

  • an AWS account with the IAM permissions listed on the EKS module documentation,
  • configured AWS CLI
  • AWS IAM Authenticator
  • kubectl installed
  • install helm

Mac Installer

brew install awscli
aws configure
AWS Access Key ID [None]: YOUR_AWS_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_AWS_SECRET_ACCESS_KEY
Default region name [None]: us-east-2
Default output format [None]: json

Set up and initialize your Terraform workspace

git clone https://github.com/maniak-academy/consul-aws-eks-terraform
cd consul-aws-eks-terraform

Initialize Terraform workspace

terraform init

Provision the EKS cluster

terraform apply -auto-approve

Configure kubectl

aws eks — region $(terraform output -raw region) update-kubeconfig — name $(terraform output -raw cluster_name)
$ kubectl cluster-info
Kubernetes control plane is running at https://CCDC5A7DBF4D10997D02A063A1C1CD70.gr7.us-east-2.eks.amazonaws.com
CoreDNS is running at https://CCDC5A7DBF4D10997D02A063A1C1CD70.gr7.us-east-2.eks.amazonaws.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

Deploy Consul on Amazon Elastic Kubernetes Service (EKS)

Create a values file

annotations: |
‘service.beta.kubernetes.io/aws-load-balancer-internal’: “true”``
global:
name: consul
datacenter: hashidc1
ui:
enabled: true
service:
type: LoadBalancer
annotations: |
'service.beta.kubernetes.io/aws-load-balancer-internal': "true"
connectInject:
enabled: true
default: true
controller:
enabled: true
ingressGateways:
enabled: true
gateways:
- name: ingress-gateway
service:
type: LoadBalancer
annotations: |
'service.beta.kubernetes.io/aws-load-balancer-internal': "true"

Install Consul in your cluster

helm repo add hashicorp https://helm.releases.hashicorp.com
helm install — values helm-consul-values.yaml consul hashicorp/consul — create-namespace — namespace consul — version “0.43.0”
$ kubectl get pods — namespace consul
NAME READY STATUS RESTARTS AGE
consul-client-9nrzh 1/1 Running 0 2m30s
consul-client-g8sgr 1/1 Running 0 2m30s
consul-client-kvx6h 1/1 Running 0 2m30s
consul-connect-injector-c47b8bc4f-8pf8m 1/1 Running 0 2m30s
consul-connect-injector-c47b8bc4f-8t4pp 1/1 Running 0 2m30s
consul-controller-5bc8cf7fc9–8hrh2 1/1 Running 0 2m30s
consul-ingress-gateway-6f6c96bd8d-2mts7 2/2 Running 0 2m30s
consul-ingress-gateway-6f6c96bd8d-b6sv5 1/2 Running 0 2m30s
consul-server-0 1/1 Running 0 2m30s
consul-server-1 1/1 Running 0 2m30s
consul-server-2 1/1 Running 0 2m30s
consul-webhook-cert-manager-859c76cdf6-rxlm9 1/1 Running 0 2m30s

Accessing the Consul UI

$ kubectl get services --namespace consul
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
consul-connect-injector ClusterIP 172.20.217.250 <none> 443/TCP 4m18s
consul-controller-webhook ClusterIP 172.20.157.192 <none> 443/TCP 4m18s
consul-dns ClusterIP 172.20.225.163 <none> 53/TCP,53/UDP 4m18s
consul-ingress-gateway LoadBalancer 172.20.99.127 ac13e16d6d7c249b6867d445483c50a2-1244103388.us-east-2.elb.amazonaws.com 8080:30037/TCP,8443:32669/TCP 4m18s
consul-server ClusterIP None <none> 8500/TCP,8301/TCP,8301/UDP,8302/TCP,8302/UDP,8300/TCP,8600/TCP,8600/UDP 4m18s
consul-ui LoadBalancer 172.20.92.25 a6ab063f2acea4b439a9a4e336a1d2f3-544204516.us-east-2.elb.amazonaws.com 80:32712/TCP 4m18s

Accessing the Bastion jumpbox

terraform output bastian_publicip
"ssh -i terraform-20220603163956775300000003.pem ubuntu@3.144.233.39"

To uninstall Helm consul

helm uninstall consul — namespace consul

Clean up your workspace

terraform destroy

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

XP(Extreme Programming) Practices, Part 1

Why Should Supply Chain Companies Use Low-Code?

How to Enable Wi-Fi on Ubuntu Server 20.04 without a Wired Ethernet Connection

Empower Your SaaS Product Using Strapi

Empower Your SaaS Product Using Strapi

THINKIUM BOUNTY FOR DEVELOPERS

[HTB] Brainfuck — Walkthrough

Visible product creation

Android Paging Library Simplified

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sebastian Maniak

Sebastian Maniak

More from Medium

Encrypt and Log EC2 Session

Terraform Basics

Using an AWS S3 Bucket to Securely Manage and Encrypt Terraform State Files

AWS S3 Bucket with versioning holding Terraform state files

Aws RDS : Production — High availability — Security — Cost effective