Terraform is like the wizard of deployment tools. It's an open-source Infrastructure as Code (IaC) tool that lets you define and provision infrastructure using a declarative configuration language. Instead of manually setting up infrastructure such as servers, databases, and other resources, you can easily describe your desired infrastructure in code using HashiCorp Configuration Language (HCL).
This article focus on project using terraform for EKS , deploying applications using respective manifest files, and an application load balancer ingress controller using Helm.
The Github repository for this project EKS Terraform with application deployment
Below contains the detailed steps in this project, ensure you have an active AWS account before getting started;
- List the contents of the terraform files
- Initialize terraform on the directory to download required providers
terraform init
- Validate the terraform file using :
terraform plan
- Apply the terraform configuraton file
terraform apply --auto-approve
Copy the output of the terraform configuration to the
~/.kube/config
Installing aws-iam-authenticator
This enables using AWS IAM credentials to authenticate to a Kubernetes cluster
curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64
chmod +x ./aws-iam-authenticator
mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
- Communicate with Kuberbetes cluster using
kubectl get all
- Get the pods in the cluster using 'kubectl get pods --all-namespaces'
- Deploy the manifest for the pods deployment
kubectl apply -f manifests/deployment.yaml
- Validate the deployment using
kubectl get pods
- Testing the deployment using the port forward
kubectl port-forward hello-kubernetes-6bf86759db-7jf7j 8080:8080
- ALB Ingress Controller can be installed with Helm
- Install Helm package
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh
- Install the collection of YAML files necessary to run the ALB Ingress Controller. Add the following repository
helm repo add incubator https://charts.helm.sh/incubator
- Install the ALB Ingress Controller in my cluster
helm install ingress incubator/aws-alb-ingress-controller \
--set autoDiscoverAwsRegion=true \
--set autoDiscoverAwsVpcID=true \
--set clusterName=terraform-eks
- Deploy the service loadbalancer on the cluster
kubectl apply -f manifest/loadbalancer.yaml
- Deploy the ingress.yaml for the service
wget https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.9/docs/examples/alb-ingress-controller.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.9/docs/examples/rbac-role.yaml
Top comments (1)
Interesting read.