Deploying a WordPress Application on Kubernetes by using Amazon Elastic Kubernetes Service(EKS)
Elastic Kubernetes Service

Deploying a WordPress Application on Kubernetes by using Amazon Elastic Kubernetes Service(EKS)

?? Hello Connections !! Welcome you all to my new article of the task based on Elastic Kubernetes Service(EKS).

TASK DESCRIPTION : Deploy a WordPress application on kubernetes by using amazon Elastic Kubernetes Service and monitor the kubernetes cluster by using prometheus.

What is EKS ? As we normally use kubernetes to manage our containers . But now a days everything is based on automation and most of use cases requires premanaged services like cloud and all. Similarly managing the entire kubernetes cluster is always harder and hence for this amazon launches one premanaged service to manage kubernetes and all of their services .The service is known as Elastic Kubernetes Service(EKS) which provides us Kubernetes As A Service.

TASK COMPLETION PROCESS :

To use amazon Elastic Kubernetes Service we have multiple ways like using WEBUI ,using CLI and using terraform code . In my task I use CLI to interact with EKS. Before using CLI for EKS we have to install eksctl command program .

No alt text provided for this image

By using this eksctl command we do all the things in EKS like creating clusters and all. Behind the scene internally eksctl command has contact to cloud formation service which do all the set up of our clusters automatically .

1)Login to aws account through CLI by IAM user and check for any cluster running in EKS by using eksctl command.

No alt text provided for this image

2)Now to create the kubernetes cluster in EKS ,I have created one YAML file in which all the cluster configuration is coded . In this code we have to configure about the node groups ,instance type and about spot instances .

No alt text provided for this image

In node groups we specify all the information about the number of nodes we require for our cluster of specific instance type.Like in my case i have created 3 node groups each of them is of t2.micro instance type.

2)We have to run this cluster.yml file by using eksctl command . Then eksctl command internally contact to aws services like ec2 for the nodes and creates the entire cluster in EKS. It will take typically 10 to 15 minutes to create the cluster.

No alt text provided for this image


#eksctl create cluster -f cluster.yml

No alt text provided for this image


No alt text provided for this image

3)Finally our cluster got created .Now we have to make some changes in kubeconfig files of our kubectl command by which kubectl command can be configured for the cluster of EKS.

#aws eks update-kubeconfig --name mycluster

No alt text provided for this image

4)For launching WordPress application we have to create WordPress deployment which runs in one of the node of our EKS cluster .For this I have created one YAML file in which all the configuration about WordPress pod is coded . To avoid the data loss and make the data permanent i have configured one persistent volume claim which is nothing but internally contact to dynamically created PV and EKS by default take storage from EBS volumes.

No alt text provided for this image
No alt text provided for this image

5)For storing the data of the user of WordPress application we have to create one mysql database which work as a back end for our application.For these I have created one YAML code for creating mysql deployment .As mysql database deployment is most critical for us since all the necessary services of kubernetes like secret and all that included in this code.

No alt text provided for this image
No alt text provided for this image

6)Finally we have to create one single file which runs all the setup sequentially for our WordPress application which is kustomisation file . I have created one kustomisation file by running this single code in one click the entire WordPress application is deployed on kubernetes done by EKS.

#kubectl create -k .

No alt text provided for this image

7)We can now get more information about all the services and nodes by running kubectl get all command.

#kubectl get all

No alt text provided for this image

8)Now as EKS provides us one public ip in the terms of URL for our WordPress application.By using this URL we can access our WordPress application .

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

9)Finally the WordPress application is deployed on the kubernetes managed by using EKS. We can also see all the things from GUI of aws that we create from CLI using eksctl command.

1)EKS cluster --> mycluster

No alt text provided for this image

2)EKS nodes -->ec2 instances

No alt text provided for this image

3)Persistent Volume Claim --->EBS volumes

No alt text provided for this image

4)Cloud formation services for our cluster

No alt text provided for this image
Monitoring the clusters running in EKS by using Prometheus

Prometheus is one of the tool used to monitor the kuberenetes cluster . To install the prometheus in kubernetes we use Helm service of kubernetes which is typically used to install any of the software or application in kubernetes by using charts .

No alt text provided for this image


1)First we have to install helm program in our system and adding repository to the helm by running the command helm init . For helm we have to install another program known as tiller which is server side component of helm .

No alt text provided for this image

#helm init

No alt text provided for this image

2)Installing prometheus on kubernetes by using helm repository . For these we have to create one namespace called prometheus inside which we launch our prometheus server pod .

# kubectl create namespace prometheus

# helm install stable/prometheus    --namespace prometheus    --set alertmanager.persistentVolume.storageClass="gp2"    --set server.persistentVolume.storageClass="gp2"

# kubectl get svc -n prometheus

# kubectl -n prometheus port-forward svc/ignorant-chicken-prometheus-server 8888:80

No alt text provided for this image

3)Now we can access prometheus by using public ip > 127.0.0.1.8888 and we can now monitor our cluster and obtian the result in graphical form .

No alt text provided for this image

4) By executing the query in prometheus we can obtain the cluster monitoring result in graphical form .

No alt text provided for this image

In this way finally I completed my task successfully .

I would like to thanks Mr.Vimal.Daga and Preeti Mam for giving such golden opportunity of EKS training and immense guidance which helps me a lot to cover all the concepts of kubernetes and EKS .

Thanking you all for reading my article









PRAFULL WAIDANDE

Ambassador & Technical Volunteer at IIEC Rise || Google Cloud Platform at LinuxWorld Informatics Pvt Ltd

4 年

Really Great ????????

回复
Chaitanya Chougule

Senior DevOps Engineer @Deltek

4 年

Great work Bhai..????

回复
Yash Walke

SDE-II at HashedIn (Deloitte-USI) | AWS Solutions Architect - Professional | BITS Pilani '25

4 年

Great ??

回复

要查看或添加评论,请登录

Onkar Naik的更多文章

社区洞察

其他会员也浏览了