Nerd For Tech
Published in

Nerd For Tech

Created by Raktim

Deploying Joomla, Prometheus & Grafana on AWS EKS

In this article you will come to know How to deploy Joomla, Prometheus and Grafana on AWS EKS. I will discussion each and every thing in details and also show you the demonstration. So let's start….

Here is the Video Demonstration of the Task :

What is AWS EKS ???

Amazon Web Services popularly known as AWS is a Cloud Service Provider. I don't want to talk much about AWS here but if you want to know more about AWS then you can read my article given below.

In AWS we have fully managed Kubernetes Service called EKS (Elastic Kubernetes Service). The great feature of EKS is here to create multi node cluster you don't have to setup anything on your own. Here simply you have to tell EKS that what resources you want to use and EKS will automatically provision those resources and also will setup everything automatically for you.

What is Joomla ???

Joomla is an open-source content management system used for creating Web content. It is written in PHP and makes use of a MySQL database for storing data and uses object-oriented programming techniques. We are going to use pre created Docker Images of Joomla and MySQL.

What is Prometheus ???

Prometheus is a free software application used for event monitoring and alerting. It records real-time metrics in a time series database built using a HTTP pull model, with flexible queries and real-time alerting. We are going to use it to monitor our Multi Node Cluster.

What is Grafana ???

Grafana is a multi-platform open source analytics and interactive visualization web application. It is expandable through a plug-in system. End users can create complex monitoring dashboards using interactive query builders. We going to connect Prometheus Database Server with Grafana to monitor our Multi Cluster Node.

Setting up the AWS EKS Cluster…

Prerequisite :

  • You should have one AWS account and also AWS CLI should be installed in your system. Next you should configure the AWS CLI with your access key and secret key.
  • Next thing you should have “eksctl” program installed on your system. eksctl is a program which can create EKS cluster very easily.
  • Also you should have “kubectl” program installed on your system. kubectl is the client program which contacts with Kubernetes Master running on AWS to fulfill our desires.

Writing the yml file to create EKS cluster :

To create cluster using eksctl we need to create one yml file. Here in below you can see the file. Don't worry I am going to discuss how to write this file.

  • In this file the 1st two option (kind and apiVersion) you can think as by default options. In metadata we mention what should be name of my cluster and in which region we want our cluster to be deployed.
  • Next in nodeGroups we mentioned which kind of nodes we want. Here I created 3 kinds of node groups with 3 different kinds of resources. It's depend upon your application load which kinds of resources you want to provide.

Creating the EKS cluster :

You only have to run one single CMD to create the cluster. In that folder where you have your cluster.yml file open the CMD prompt and run this CMD mentioned below.

eksctl create cluster -f cluster.yml

Next in the below mentioned pics you can see I run the CMD.

Next If I go to AWS and go to EKS, we can see that the Cluster has been created.

If I go to Cloud Formation in AWS, we can see that cloud formation created the cluster, Node Groups, VPC and everything that is needed.

Also if I go to EC2, we can see total 5 Instances have been deployed successfully.

So, finally cluster is ready to use.

Configuring kubectl :

So, we are going to run the below mentioned cmd which will setup the kubeconfig file.

aws eks update-kubeconfig --name rmcluster 

Congratulations, we are done with whole setup of Kubernetes. Now we can easily deploy our applications.

Deploying Joomla…

We have to create 3 yml file to deploy Joomla. I am going to discuss all the files one by one.

MySQL Deployment file :

Using this below mentioned file we going to create MySQL pod which will work as database for Joomla.

  • I already told about apiVersion, kind and metadata. Now in spec we told on which port MySQL work and also which kind of Kubernetes service we want for MySQL. Now I don't want outsiders can access my database. So, I used clusterIP service.
  • Next I created one pvc which will make my MySQL data permanent. Means If due to any reason my pod gets terminated I won't loose anything.
  • Next I created one deployment file to deploy MySQL pod. Here one thing we can notice that the password of MySQL is coming from another file. Usually we create one secret file and inside that we securely save our passwords and give the location of that file. Now my deployment automatically retrieve that password from that file. Also one more thing I attached the pvc to “/var/lib/mysql” folder cause MySQL saves it's data inside this folder.

Joomla Deployment File :

Using this below mentioned file I created the pod for front-end Web App Joomla.

  • Here also every point I have discussed previously. But instead of Cluster IP, here I used LoadBalancer cause this is our front-end app and this LoadBalancer will give me one public DNS and we give that to clients, so that clients can see my site.
  • Also one thing here we mentioned our Database details so that Joomla can connect to the Database.
  • One more last thing here I make my “/var/www/html” folder persistent cause we are using Joomla on top of Apache webserver. Apache webserver stores it's data inside this folder.

Kustomization File :

This is the final file that we have to write. This file will automatically find out other files and will run them. You can think this as a small automation. Rather than we manually run each file we simply mention the files names in it. Remember one thing the name of this file is fixed.

  • One more thing here in this file we mentioned our secret key which we pass on MySQL and Joomla. So, this will generate the Secret for us.

Let's Run these files and let's find out how to access Joomla :

At first it's always good practice to create the namespace for each purpose. This makes the things organized. I also at first created one namespace called Joomla using

kubectl create namespace joomla

Then I changed default namespace to Joomla using

kubectl config set-context --current --namespace=joomla

Next I run one simple CMD to deploy the MySQL and Joomla. The CMD is

kubectl create -k .

So, finally my complete setup is ready. Now I run “kubectl get all” and got the External-IP. Now if I go to this IP after 5 minutes we will see that the Joomla is running. This 5 minutes it takes cause AWS creates one LoadBalancer.

Let's see how to setup Joomla…

In 1st page just fill up the basic informations like site name, email, username and password.

In next page we have to setup the database details. In Host name type “joomla-mysql” cause this is the name of our MySQL deployment. Next in username type “root”. You can also create one user in Database but for that you have to write some more extra lines on MySQL deployment file. In password give that password that you stored in that Secret file. In Database name give “joomla” and it will create one Database called joomla.

Finally run the installer and within few seconds your Web App will be ready to use. Next you will get one login scree, simply login and you will see this kind of page given below.

Deploying Prometheus…

Prerequisite :

  • You need to have helm and tiller program installed on your system. Before deploying Prometheus we going to setup helm and tiller.

Setup the Helm :

You just simply have to run 3 CMD to setup the helm. The commands are mentioned below.

helm inithelm repo add stable repo update

Setup the Tiller :

Here also we going to run few CMDs. This will create one service account for tiller so that tiller can deploy our required resources like pods, pvc etc. The CMDs are below mentioned.

kubectl -n kube-system create serviceaccount tillerkubectl create clusterrolebinding tiller — clusterrole cluster-admin — serviceaccount=kube-system:tillerhelm init — service-account tillerhelm init — service-account tiller --upgrade

Prometheus deploy using helm :

Now we can easily deploy Prometheus using helm. So, here we run three CMDs to deploy Prometheus. 1st one is to create one namespace for Prometheus and Next one to deploy and the last one to get the IP one Prometheus server so that we can integrate this with Grafana.

kubectl create namespace prometheushelm install stable/prometheus --namespace prometheus --set alertmanager.persistentVolume.storageClass=”gp2" --set server.persistentVolume.storageClass=”gp2"kubectl get svc -n prometheus

So, finally you will see that Prometheus have been successfully deployed.

Deploying and Setting up Grafana…

Grafana deploy using helm :

Same as we did for Prometheus, here also we going to run 3 CMDs.

kubectl create namespace grafanahelm install stable/grafana --namespace grafana --set persistence.storageClassName=”gp2" --set adminPassword=grafana --set service.type=LoadBalancerkubectl get svc -n grafana

One thing to notice that in Grafana by default the login username is “admin”. While running the helm cmd of Grafana we setup the admin account password as “grafana”. You can set whatever you want. Next we get the external IP so now lets go to this IP to explore Grafana.

Setting up Grafana :

At first login to Grafana and after login you will find one option called Data Resource. Click on that and select Prometheus. Now we have to provide the Host address of Prometheus Server. So, here give the Prometheus Server IP address and save it.

Just to follow in below I have shown the screenshots.

Next Click on the plus icon (+) on left side and click on Import. Next give the value “10000”. Actually this is pre created Dashboard for Kubernetes Multi Node Cluster. Next select the Prometheus and next click on Import. Then you will be able to see complete Monitoring of Kubernetes all the Cluster and everything.

Just for reference here are the screenshots shown below.

So, finally it's done. So, this was the task.

Now, I will show you how easily we can completely destroy the complete task…

Let's Destroy our all Deployments means let's destroy Joomla, MySQL, Prometheus and Grafana.

To destroy Joomla and MySQL we going to run 3 CMDs. Actually the 1st CMD is enough to delete the Joomla and MySQL. But we will also delete the pvc and secrets. The CMDs are mentioned below.

kubectl delete all --allkubectl delete pvc --allkubectl delete secrets (secret name)

Next as we used Helm for Prometheus and Grafana so we don't need to manually delete everything. Only two CMDs and everything will be destroyed.

helm listhelm del (name of your deployment) --purge

Now Let's Delete the Complete EKS Cluster :

We just need to run one CMD and the complete Cluster will get destroyed.

kubectl delete cluster -f cluster.yml

Also Now if you see Cloud Formation on AWS you will see that it started the deletion process.

Alright, thanks everyone for Reading. I really enjoyed while doing this task. Signing off for now. Bye Bye 👋 …



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Raktim Midya

Raktim Midya


Technical Content Writer || Exploring modern tools & technologies under the domains — AI, CC, DevOps, Big Data, Full Stack etc.