Deployment of Wordpress & MySql on Amazon EKS
Writing this article to illustrate about the task that was assigned. The task was to create a kubernetes cluster on top of amazon web services. For this purpose amazon has a service named as EKS. Here i am deploying my wordpress site on top of EKS and for storing its content, I have also used MySQL database on EKS.
Let us start with getting bit familiar with the terminologies used above and within the task.
- Kubernetes (K8s) - Is an open-source system for automating deployment, scaling, and management of containerized applications.
- Amazon web services - Provides on-demand cloud computing platforms and APIs to individuals, companies, and governments, on a metered pay-as-you-go basis
- EKS - Elastic kubernetes services - 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. EKS is deeply integrated with services such as Amazon CloudWatch, Auto Scaling Groups, AWS Identity and Access Management (IAM), and Amazon Virtual Private Cloud (VPC), providing you a seamless experience to monitor, scale, and load-balance your applications. EKS provides a scalable and highly-available control plane that runs across multiple availability zones to eliminate a single point of failure.
- YAML - YAML is a human-readable data serialization language. It is commonly used for configuration files, but could be used in many applications where data is being stored or transmitted.
Now for connecting to EKS we have 3 ways i.e., WebUI, CLI and Terraform.
Here I am using CLI for performing the above task. Now lets start with the task.
The first thing we need is to configure our AWS with a particular user to create our cluster on top of EKS for this we have to provide access key, secret key and region where we want to launch the cluster.
By running the above commands we can easily check whether AWS is configured and eksctl is working or not
Now for using EKS in the CLI we have to set up a command name eksctl for which we have to download the same command in our folder where minikube is running. For downloading the command you can use official site.
After setting up eksctl the next step is to configure the cluster on top of aws. For creating cluster we need some kind of programming language. Here we are using YAML for the same.
Now after configuring YAML file we'll launch our cluster using the following command -
eksctl create cluster -f 'create-cluster.yml'
As soon as the cluster is launched it will create nodes in EC2 instances.
After launching the cluster we have to update our config file so that it can use amaozn EKS cluster in place of minikube. After updating the configuration file we can check the nodes running on EC2 instance.
Now for deploying wordpress & MySQL we can use default namespace but here we are creating our own namespace by using below command -
kubectl create namespace "eks"
After creating namespace we can create our pod for which we have configured YAML file
Now for exposing our pods to the outer world we can use service named load balancer.
As soon as the pod is exposed it can be easily accessed from any IP
For scaling our pods we can create replica for the same.
After launching the pods we will go inside the pod and run the following code to check whether it is working or not.
After this we will start creating PVC using YAML file. As soon as the PVC is created we have to mount it to the particular pod to bring it in running state.
As soon as we mount our container starts running with PVC attached to it.
Now we will launch our storage for storing the data
Till now we have exposed our pod and created a storage. Now the main part to deploy the wordpress and MySQL site come into the picture. For which we are again using YAML file
After configuring the YAML file we will deploy each of them one by one. And for getting the status we will use the following command.
As soon as our wordpress site is up, we will create our login credentials for using it and start collecting data.
Here I have created one post to check whether the above setup is working fine or not.
This the final outcome on the wordpress portal
With this I conclude the completion of this article any suggestion would be welcome .