Deploying EKS Cluster on AWS

Akhilesh Jain
7 min readJul 11, 2020

AWS

Amazon Web Services (AWS) is a subsidiary of Amazon that provides on-demand cloud computing platforms and APIs to individuals, companies, and governments, on a metered pay-as-you-go basis. In aggregate, these cloud computing web services provide a set of primitive abstract technical infrastructure and distributed computing building blocks and tools.

What is EKS ?

Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed Kubernetes service. Customers such as Intel, Snap, Intuit, GoDaddy, and Autodesk trust EKS to run their most sensitive and mission critical applications because of its security, reliability, and scalability.

Working of EKS

Use Cases of EKS are :-

  • Hybrid Deployment
  • Batch Processing
  • Machine Learning
  • Web Applications

Stepwise Procedure for deployment of EKS on AWS :

Use only need a AWS account for this deployment and open the AWS Management Console.

AWS Management Console

Then goto Services and then you will be observing Iam subservice in Security, Identity and Compliance.

Services

Then create a new Iam user in this and give this user Administrator Access.

Iam page

Then click on Users in Iam Resources and create a new user and give any name to this user and in access type -give programatic access to use this user in cli, sdk and on may more platforms.

Create User by clicking on Add User
Give administrator access to this user

Create the user and copy this access key and security access key as it will be shown only once.

Now goto CMD and use command aws configure and enter your keys.

Here, to create cluster we are using “eksctl” command which is another tool by Weaveworks. You just have to download the exe file for this and create a env path for this .exe application. Use eksctl version for verifying . I will be providing this setup file in my github link below.

official website of eksctl

-> Eksctl uses YAML file for cluster creation. So, I will be creating this file having 3 EC2 Instances which will be working as my nodes.

eks-cluster.yml

use this command to create cluster : eksctl create cluster -f eks-cluster.yml . This command is so powerful that it will create all your cluster with the given specifications in YAML file. Eksctl takes around 10–15 minutes for creation of cluster.

-> When Eksctl creates cluster, you can see on AWS’s EKS dashboard that your cluster is created.

EKS cluster created

We can also see our nodes on EC2 Dashboard.

3 instances in a worker node running

-> We have to install a package called “amazon-efs-utils” in our instances.

installing package on instance 1 (a)
installing package on instance 1 (b)
installing package on instance 2(a)
installing package on instance 2(b)
installing package on instance 3(a)
installing package on instance 3(b)

-> Eksctl uses AWS’s CloudFormation service to create all the required services in our cluster. Below is the screenshot of my CloudFormation after creation.

CloudFormation

To use Kubernetes Cluster on your system, you have to save the configuration file of master on your system using this command below :-

# aws eks — region ap-south-1 update-kubeconfig — name eks-cluster

After this, you can use this cluster using kubectl command.

In this Deployment, I have used AWS EFS service for my persistent storage as it is available in all subnets in a provided region, so if a pod fails then automatically it will be available for the new pod. Remember to give security groups same as of the instance as they are the one which will request for storage.

EFS

We will be using EFS as our Storage Class and PVC will be requesting to this for storage and PV will be dynamically created . I have used sc-pvc-provioner.yml , rbac.yml , sc-pvc.yml to create my Storage Class and PVC. You will get all the files in github link below.

I have created a namespace “secure” , so that all our deployments can be in like 1 room called namespace.

creating provisioner for storageclass
Provisioner pod is running
Provisioner description (a)
Provisioner description (b)

The above ss are related to the pod we create to use storage class using EFS.

rbac creation
  • Rbac is used for security of our provisioner pod.
creation of Storage Class and Pvc

Above command will create our storage class and our PVC (persistent storage) for our mysql and wordpress pods.

2 PVC created from above command
Description of Mysql PVC
Description of Wordpress PVC
Description of PV of Mysql and Wordpress

You can observe from file that PV are dynamically created, we have only created PVC for pods.

We will create secret for our pods environment variables for security and it is always a good practice to create the secret for storing passwords.

create secret using the above command
description of our secret

Now we will create Mysql pod which will be used as database for our wordpress.

creation of mysql deployment and service
Description of Mysql deployment
ClusterIP Service created (you can see in yml file for syntax)
Description of Mysql pod (a)
Description of Mysql pod (b)

As Mysql deployment and Service are successfully created, so now we will create our frontend which is Wordpress.

creation of wordpress deployment and service
Description of Wordpress deployment
Service Loadbalancer is created which will expose a pode for this pod for accessing.
Description of Wordpress pod (a)
Description of Wordpress pod (b)

The Load Balancer created from this YAML file will use AWS’s ELB (Elastic Load Balancer) as service.

AWS ELB service

Using Domain name of ELB, wordpress dashboard will arrive successfully and hence our architecture of deploying mysql on backend and wordpress on frontend is complete.

To delete our created eks cluster, use following command :

deleting cluster

Github Link for all the codes and eksctl.exe :-

“I practiced and gained knowledge mentorship of Mr. VIMAL DAGA Sir during the “EKS TRAINING” organised by Linux World India.”

I hope this article is Informative and Explanatory. Hope you like it !!!

For any suggestions or if any reader find any flaw in this article, please email me to “akhileshjain9221@gmail.com”

Thank You Readers!!!

--

--

Akhilesh Jain

I am a student and persuing under graduation in computer science and engineering.