How to Deploy Kubernetes cluster on Amazon EKS

data codes through eyeglasses
Reading Time: 4 minutes
Amazon EKS - Turbonomic

Hello Readers! In this blog we are going to learn How to Deploy Kubernetes cluster on Amazon EKS. Before starting we will firstly see What is Amazon Elastic Kubernetes Service (Amazon EKS)?

Amazon Elastic Kubernetes Service (Amazon EKS)

Its a simple command-line utility for generating and maintaining Kubernetes clusters on Amazon EKS. At the end of this tutorial, you will have a working Amazon EKS cluster that you can deploy applications.

Amazon EKS clusters

An Amazon EKS cluster consists of two primary components:

  • The Amazon EKS control plane.
  • Amazon EKS nodes that are enrolled with the control plane.

Let’s get started !

Pre-requisites:

An EC2 Instance

Step 1: Setup AWS EKS

  1. First we will Setup kubectl
    • a. Download kubectl version 1.20 using below command.
    • Grant execution permissions to kubectl executable.
    • Move kubectl onto /usr/local/bin.
    • Test that your kubectl installation was successful.
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin 
kubectl version --short --client

Step 2. Setup eksctl

a. Download and extract the latest release
b. Move the extracted binary to /usr/local/bin
c. Test that your eksclt installation was successful

curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname-s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version

Step 3: Create an IAM Role and attache it to EC2 instance

  • IAM user should have access to
  • IAM
  • EC2
  • VPC
  • CloudFormation

Step: Firstly you must have an AWS account before starting. So, Create an AWS account if you don’t have one. After that Login to your AWS account and Click on Services menu > Choose IAM role and attach to the EC2 instance.

Let’s get started as Pre-requisites we have setup our EC2 instance and if you want to know how to create this you can go through this below link: https://blog.knoldus.com/aws-ec2-instance/

Create an IAM Role and attache it to EC2 instance

Now it’s time to connect to this EC2 instance, so before start i will create one IAM role, i will click on roles and after that click on create roles and we are attaching to the EC2 we will select EC2 and Next.

And privileges we need to give IAMFullAccess, click on Next and CloudFormation because everything is run with CloudFormation itself, this is another privilege and AmazonVPCFullAccess and last privilege is AmazonEC2FullAcess and click on Next, i’m going to give it to name Applicatio_role, so we are giving to these privileges along with the administrative privilege and click on create role.

We have created an IAM role now this role we need to attach it to our EC2 instance , so let’s go back and select our EC2 instance actions it will come under to security group modifying role and Application_role.

Step 4: Create your cluster and nodes

Now its time to execute our eksctl command so that we will create a cluster i’m going to select this command.

eksctl create cluster --name cluster-name  \
--region region-name \
--node-type instance-type \

example:
eksctl create cluster --name Demo-cluster \
   --region ap-south-1 \
--node-type t2.small 

Cluster and Nodes

Let’s go back and execute it on your shell, it’s going to take atleast 15-20 min to setup we need to wait for that so it is setting up the kubernetes version that is the one it is going to do and this is the subnets, you can see here it is using three subnets it can create among these three in any two availability zones by default two are the minimum and maximum, so let’s wait.

And Click on and check in our CloudFormation yes it’s compeleted and it is running on the new one that is demo cluster.

Step 5: Our cluster is ready and kubectl will look after for the master node in this configuration and it communicate with that one but in this service the master node is managed by the AWS itself, so you cannot able to see the master node in our EC2 instances and to validate it we can just execute.

kubectl get nodes

It is going to list out the number of nodes which are associated with this cluster.

So here is the General Configuration of our demo cluster you can see all the necessary VPC, Subnets, Security groups and so many things, So we have created the kubernetes cluster using Amazon Elastic Kubernetes Service.

Conclusion:

Therefore In this blog we saw with a few easy steps how we can How to Deploy Kubernetes cluster on Amazon Elastic Kubernetes Service and you can also change the configuration as per your requirement. Thanks for being with me till the end. If you find this blog helpful do share with your friends.

HAPPY LEARNING!

knoldus

Written by 

I am an enthusiastic , hard-working and determine girl with strong attention to detail and eager to learn about new technologies.