How to deploy Rancher on the EKS cluster using Helm?

rancher eks
Reading Time: 3 minutes

Hey readers, so today we’ll see how can we deploy Rancher on the EKS cluster using Helm. Firstly we’ll create an EKS cluster on AWS using Terraform and then we’ll deploy Rancher on EKS using Helm charts. So for that, we’ll be requiring some prerequisites.

  • An AWS account with admin privileges
  • AWS CLI on the local system
  • Configured CLI with the respective AWS account
  • Terraform installed on the local system
  • Kubectl on the local system
  • eksctl on the local system
  • Helm on the local system

Configuration for EKS

Now, we will create terraform files for our EKS to configure it on AWS. For the same, first, we’ll create a directory with any name you want. I’ll be naming it as EKS-Terraform. Now we’ll generate a key pair for getting access to our cluster. For the same, the command will be:

ssh-keygen -t rsa -f ./eks-key
How to deploy Rancher on the EKS cluster using Helm?

After that, we will create a file with the name provider.tf for specifying the region. The file will look like the below:

How to deploy Rancher on the EKS cluster using Helm?

Now we’ll create a file with the name cluster.tf which will include our modules for a virtual network, cluster, and pool. But first, we’ll add a block for local to define the name of the cluster locally which can be used in different modules.

Next, we will set up the network for our cluster using the Fairwinds AWS VPC module(Kubernetes configuration validation software). Also, we’ve to use a 16/CIDR block with a subnet of /21 CIDR block.

How to deploy Rancher on the EKS cluster using Helm?

Now we’ll define the module for the cluster itself.

How to deploy Rancher on the EKS cluster using Helm?

Creating the EKS Cluster

Now the config files are completed, we’ll use Terraform to make the cluster up on EKS. For the same, we’ll initialize the terraform script and then validate the generated artifacts. For this, we’ll use the below commands:

terraform init

After that

terraform plan

When the plan gets validated, then we’ll have to apply the changes by running the below command:

terraform apply

It will take around 20 mins in the process and after that, you can interact with your cluster. for that, you have to run the below command:

aws eks --region us-east-1 update-kubeconfig --name first-cluster

The next command to check the nodes of your cluster is:

kubectl get nodes

So this is how we can make our EKS cluster on AWS using Terraform. Now, we’ll deploy rancher on the AWS EKS cluster.

Installing Ingress to access Rancher

Here we need an ingress controller to access Rancher. For installing an ingress controller with a Loadbalancer, run the below commands:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update

Now, after updating the helm chart, we’ll install the required services:

helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx 
--set controller.service.type=LoadBalancer --version 3.12.0 --create-namespace

After that, we need to get the address of the load balancer so that we can set up the DNS as it will be used as the URL for the Rancher server. Run the below command:

kubectl get service ingress-nginx-controller --namespace=ingress-nginx

Now to set up the DNS, you guys can refer to the AWS official documentation.

Deploying Rancher

Now we’ll add the helm chart for Rancher to get installed on our system. For the same, run the below command:

helm repo add rancher-latest https://releases.rancher.com/server-charts/latest

Creating a namespace for rancher to get deployed:

kubectl create namespace rancher

Then we’ll install cert-manager as rancher is configured to be secure by default and requires SSL/TLS configuration.

kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml

helm repo add jetstack https://charts.jetstack.io

helm repo update

helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.5.1

After that, we’ll install the rancher using the helm chart.

helm install rancher rancher-latest/rancher \
  --namespace rancher \
  --set hostname=rancher.my.org \
  --set replicas=3

To check whether the deployment is successful or not, we can with kubectl like below:

kubectl -n rancher rollout status deploy/rancher

So this is how we can set up Rancher on the AWS EKS cluster using Helm. For more info, click here.

Written by 

Shubham Saini is a DevOps Engineer who loves to play with DevOps tools, Security methods and is also interested in Ethical Hacking & Cyber Security. He is a gamer also.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading