Step-by-step guide to deploy Rancher on AWS EKS using Terraform and Helm Charts.
AWS Cloud Hands-on Lab Practice Series
Project Overview —
This project revolves around AWS EKS where we deploy Rancher (platform for Kubernetes management). Rancher is a Kubernetes management tool to deploy and run clusters anywhere and on any provider. Amazon EKS & Rancher is a vital combination when it comes to managing multi-cluster Kubernetes workloads from a Single Dashboard.
SOLUTIONS ARCHITECTURE OVERVIEW -
First, let’s understand the real-world use case:
Hybrid Cloud Management for a Global E-Commerce Platform:
Imagine a large e-commerce platform that serves customers globally. The platform’s infrastructure spans multiple regions to ensure low-latency access and high availability. Rancher provides a unified dashboard for managing EKS clusters spread across various regions.Finance: Multi-Tiered Application Deployment:
A financial institution is migrating its legacy monolithic applications to a microservices architecture on AWS EKS. Rancher simplifies the deployment of microservices across EKS clusters in different regions.Retail: Seasonal Application Scaling:
A retail chain experiences significant fluctuations in website traffic during holiday seasons. Rancher enables automated scaling of applications based on predefined policies.Manufacturing: Edge Computing for IoT Devices:
A manufacturing company utilizes IoT devices across its facilities to monitor and optimize production processes. Rancher supports the deployment of Kubernetes clusters at the edge, close to IoT devices.Media and Entertainment: Content Delivery Optimization:
A media streaming service operates globally and needs to optimize content delivery for users. Rancher integrates with AWS services like Amazon CloudFront for efficient content caching.
These diverse use cases demonstrate the versatility of Rancher on AWS EKS in addressing industry-specific challenges and enhancing the management of Kubernetes clusters in various contexts. Rancher simplifies operations, enhances security, and provides a unified platform for managing the hybrid cloud environment.
Prerequisite —
- AWS ACCOUNT with admin privileges.
- AWS EC2 Instance (Bastion Host)
- Terraform Installation Guide
- HELM Installation Guide
- KUBECTL Installation Guide
AWS Services Usage —
- AWS EKS
- AWS IAM
- AWS EC2
- AWS ELB
- AWS VPC
Step-by-Step Guide -
Step 1: Clone the repo & check the versions of installed tools
- Login to AWS EC2 instance (Bastion Host).
- Install tools — Terraform, helm, kubectl, aws cli.
- Check versions:
aws version
,kubectl version
,helm version
. - Now clone the Git Repo: Terraform Repo Link
- Give Star & Follow me on GitHub
- Repo has 3 files —
main.tf
,variables.tf
, &terraform.tf
Step 2: Deploying AWS resources through Terraform.
Now go to the folder location & run below commands.
Terraform init
Terraform validate
Terraform plan
Terraform apply
- This will deploy infrastructure resources in AWS.
- It will take around 15–20 mins to get it deployed.
- It will have 1 EKS master cluster & 2 worker nodes (ec2 spot instances) attached to the AWS EKS master cluster.
STEP 3 : Add Helm Repositories
helm repo add devpro https://devpro.github.io/helm-charts
This repository contains Helm charts to build clusters with all components running in containers.
helm repo add jetstack https://charts.jetstack.io
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo update
helm repo list
STEP 4 : Access the EKS Cluster through kubectl
- Run below mentioned commands from EC2 Bastion:
aws eks - region me-south-1 update-kubeconfig - name <eks_cluster_name>
kubectl get nodes
kubectl get all -A
TIP — If you face any permission issue then change permission for ~/.kube/config
This confirms that Cluster on EKS is ready with requested worker nodes.
STEP 5 : Ngnix Ingress Installation (exposing to Internet)
- Run below mentioned command :
helm upgrade --install \
ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.service.type=LoadBalancer \
--version 4.8.3 \
--create-namespace
Check the services: kubectl get services -n ingress-nginx
Copy & save Loadbalancer DNS ( It will used in step 7)
STEP 6 : Install Certificates manager.
Set env variables
CERT_MANAGER_VERSION=v1.12.4
RANCHER_VERSION=2.7.6
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.crds.yaml
helm upgrade --install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version $CERT_MANAGER_VERSION
- Check the pods : kubectl get pods -namespace cert-manager ( 3 pods should be in Running status)
- Lets have new certificate from letsencrypt
helm upgrade --install letsencrypt devpro/letsencrypt \
--set registration.emailAddress=$EMAIL_ADDRESS \
--namespace cert-manager
- Now run this command : kubectl get clusterissuer -n cert-manager ( 2 Cluster issuers should be True)
STEP 7 : Install Rancher
- kubectl create namespace cattle-system
helm upgrade --install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=<LOAD_BALANCER_DNS> \
--set 'ingress.extraAnnotations.cert-manager\.io/cluster-issuer=letsencrypt-prod' \
--set ingress.ingressClassName=nginx \
--set ingress.tls.source=secret \
--set ingress.tls.secretName=rancher-tls \
--set replicas=2 \
--version $RANCHER_VERSION**
- Check the status of installation & wait for it to complete.
kubectl -n cattle-system rollout status deploy/rancher
kubectl get secret - namespace cattle-system bootstrap-secret -o go-template='{{ .data.bootstrapPassword|base64decode}}{{ "\n" }}'
STEP 8 : Accessing the Rancher UI
Copy Load balancer DNS URL & Paste on browser for Initial setup of Rancher.
You will be asked for password ( copied earlier )
Hit Log in with Local User.
Define the admin password, check the box and click on “Continue”. (store it)
Finally, Rancher is running and you can explore “local” cluster.
STEP 9 : Check AWS EKS Console
STEP 10 : Decommission
- Run below command to destroy all resources.
kubectl delete ns cert-manager
kubectl delete ns ingress-nginx
terraform destroy --auto-approve
Congrats ! We have successfully completed lab for Deploying Rancher on AWS EKS using Terraform & Helm Charts.
I am Kunal Shah, AWS Certified Solutions Architect, helping clients to achieve optimal solutions on the Cloud. Cloud Enabler by choice, DevOps Practitioner having 8+ Years of overall experience in the IT industry.
I love to talk about Cloud Technology, DevOps, Digital Transformation, Analytics, Infrastructure, Dev Tools, Operational efficiency, Serverless, Cost Optimization, Cloud Networking & Security.
aws #community #builders #devops #eks #managed #kubernetes #solution #rancher #solution #management #centralize #dashboard #easy #management #scalability #operational #efficiency #robust #infrastructure #highly #available #reliable #controlled #design #acloudguy
You can reach out to me @ acloudguy.in
Top comments (0)