Deploying EKS Cluster on AWS
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.
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.
Then goto Services and then you will be observing Iam subservice in Security, Identity and Compliance.
Then create a new Iam user in this and give this user Administrator Access.
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 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.
-> 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.
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.
We can also see our nodes on EC2 Dashboard.
-> We have to install a package called “amazon-efs-utils” in our instances.
-> Eksctl uses AWS’s CloudFormation service to create all the required services in our cluster. Below is the screenshot of my CloudFormation after creation.
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.
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.
The above ss are related to the pod we create to use storage class using EFS.
- Rbac is used for security of our provisioner pod.
Above command will create our storage class and our PVC (persistent storage) for our mysql and wordpress pods.
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.
Now we will create Mysql pod which will be used as database for our wordpress.
As Mysql deployment and Service are successfully created, so now we will create our frontend which is Wordpress.
The Load Balancer created from this YAML file will use AWS’s ELB (Elastic Load Balancer) as 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 :
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!!!