Deploy Consul on AWS EKS using Terraform and Helm

Prerequisites

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
git clone https://github.com/maniak-academy/consul-aws-eks-terraform
cd consul-aws-eks-terraform
terraform init
terraform apply -auto-approve
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
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
$ 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
terraform output bastian_publicip
"ssh -i terraform-20220603163956775300000003.pem ubuntu@3.144.233.39"
helm uninstall consul — namespace consul

Clean up your workspace

terraform destroy

--

--

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