Deploy Joomla on Web-Server Using AWS-EKS
What is Amazon EKS?
Amazon Elastic Kubernetes Service is a fully managed service of kubernetes, you can also call it kubernetes as a service. EKS is the best place to run Kubernetes for several reasons.
1. You can choose to run your EKS clusters using AWS Fargate, which is serverless compute for containers. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.
2. EKS is deeply integrated with services such as Amazon Auto Scaling Groups, AWS Identity and Access Management (IAM), CloudWatch, Amazon Virtual Private Cloud (VPC), etc. providing you a seamless experience to monitor, scale, and load-balance your applications.EKS gives Serverless Option (Farget), Security and built with the community.
3. EKS provides a scalable and highly-available control plane that runs across multiple availability zones to eliminate a single point of failure.
What is Docker?
Docker is a containerization tool. Using Docker we can launch the entire environment for our application server just in 1 second. Docker run in a isolation world so it is very secure to deploy our application on top of docker container.
What is Kuberntes?
Kubernetes is a management (orchestration) tool of container. Kubernetes doesn’t launch the container, it ask/contact the docker/podman/cri-o behind the scene to launch the container if requirement comes. Kubernetes is meant for only one thing to manage the container. Here in EKS in these practical we are using docker to launch our application on docker container.
To know more about Kubernetes and Docker you can go through this article:
For this task we are going to deploy Joomla using AWS-Elastic Kubernetes Service.
What is Joomla?
Joomla is a free and open source content management system (CMS) for publishing web content, developed by Open Source Matters, Inc. It is built on a model view controller web application framework that can be used independently of the CMS. Joomla is written in PHP, uses object oriented programming techniques (since version 1.5) and software design patterns, stores data in a MYSQL, MSSQL (since version 2.5), or PostgrsSQL (since version 3.0) database. In this practical I have used MYSQL database.
Before deploying joomla we have to first install some components in our local system and set the path (environment variable path).
1. AWS CLI : Use to manage the aws services.
2. Kubectl: Use for communication with master cluster API server.
3. Eksctl: Use to create and manage entire kubernetes cluster on aws eks.
Workflow of Task:
Here you can go through this video to understand the complete workflow of this task.
These are all YAML file which I have used in this task.
pkcluster.yaml
pk-efs-provisioner.yaml
pk-rbac.yaml
pk-storage-class.yaml
pk-deploy-mysqlyaml
pk-deploy-joomla.yaml
kustomization.yaml
Here you can go through this video, I explain all YAML file in detail.
To know more bout rbac go through this link:
Step1 → Creating an AWS IAM role account.
AWS Identity and Access Management (IAM) enables you to manage access to AWS services and resources securely. Using IAM, you can create and manage AWS users and groups, and use permissions to allow and deny their access to AWS resources. Remember for these task you have to us admin account with full power.
When account is created we get access key and secret key so note it down because we gonna need these access key and secret to login into AWS using CLI. To configure and use aws service we need AWSCLI so install AWSCLI and set the path.
AWS Config is a service that enables you to assess, audit, and evaluate the configurations of your AWS resources. Config continuously monitors and records your AWS resource configurations and allows you to automate the evaluation of recorded configurations against desired configurations.
Command to login in AWS account:
aws configure
After these command run we have to paste the access key and secret key.
Step2 → Create EKS Cluster using EKSCTL
So to create EKS Cluster we have to first install EKSCTL and set the path. To create EKS cluster from CLI we need to write a YAML file (Manifest file) which contain all details as what we need.
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfigmetadata:
name: pkcluster
region: ap-south-1nodeGroups:
- name: ng1
desiredCapacity: 1
instanceType: t2.micro
ssh:
publicKeyName: instancekey
- name: ng-mixed
minSize: 2
maxSize: 5
instancesDistribution:
maxPrice: 0.017
instanceTypes: ["t2.micro", "t3.small"] # At least one instance type should be specified
onDemandBaseCapacity: 0
onDemandPercentageAboveBaseCapacity: 50
spotInstancePools: 2
ssh:
publicKeyName: instancekey
Using these command we gonna create a EKS Cluster.
eksctl create cluster -f pk-cluster.yml
It will take around 20–25 minutes to create entire cluster.
Finally Cluster is created you can see:
Here you can go through this video to know how to configure aws and create EKS Cluster:
Step3 → Update .kube/ config file
Now we have to download kubectl and then set the path. We gonna use aws update command to update the config file of kubernetes locally. When we update the .kube config file then only kubectl get the access to go in eks cluster. In these config file complete eks cluster information and access is mentioned. Without these we kubectl command can’t go inside the eks cluster and launch the POD in slave node.
Command to update the config file of kubernetes:
aws eks update-kubeconfig --name eks-cluster-name
Step4 →Create EFS Server and install amazon-efs-utils in every worker node/instance.
Now we have to keep our PODS data persistent, that means if any pod fails due to any reason we can recover the data very fast. For these we have 3 option in AWS:
- AWS uses EBS to launch the instance. If we attach external ebs to instance then it is persistent in nature. But limitation of ebs is that we can’t use 1 data center’s ebs in other data center.
- 2. In AWS object storage is S3. In S3 we can store the unlimited data. Normally we use S3 to store our static data (which don’t change). Limitation of S3 is that if developer send a code file we can’t do edit of that file.
- In AWS EFS, aws create a EFS server in all 3 data center because of disaster management. It give high availability, elasticity, scalability and all EBS and S3 limitation can be solve by EFS.
For this task I am using EFS (Elastic File System) for persistent storage. After NFS server created we have to do some changes in YAML file of efs provisioner(Add system_id and NFS server in efs provisioner file) and then we have to install a package call amazon-efs-utils in every worker nodes/instances. You can watch these complete part in this video.
Step5 →Deploy Joomla
Firstly I am creating a namespace of my name which I am going to use for this task and then run all these YAML file using kustomization.
Kustomication YAML file:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
secretGenerator:
- name: mysql-pass
literals:
- password=redhat
resources:
- pk-efs-provisioner.yaml
- pk-rbac.yaml
- pk-storage-class.yaml
- pk-deploy-mysql.yaml
- pk-deploy-joomla.yaml
Run this command to run kustomization yaml file:
kubectl create -k path-of-all-yaml-file -n prakashns
Here you can see Joomla and MYSQL PODS are running. Now using load balancer DNS name client can access joomla application.
Output:
Finally Joomla successfully deployed. All data of Joomla and MYSQL Database is storing in EFS, If any POD fail client won’t face any downtime.
Here you can watch, How I deploy Joomla using AWS-EKS:
GitHub :
Thank-you for reading.
If this article is helpful, it would be appreciable if you could give 1 clap for it.