Launching Joomla With Amazon EKS
Nishant Singh
Senior Software Engineer@HCL Tech | Red Hat Certified System Administrator | AWS Certified Solution Architect-Associate | AWS Certified Developer Associate | AWS Cloud Practitioner Certified
What is AWS EKS?
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that makes it easy for you to run Kubernetes on AWS without needing to install and operate your own Kubernetes clusters. Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications.
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.
Task :
We are going to going create a kubernetes cluster using EKS and by using kubernetes we deploy two deployments first is Joomla (For our CMS site..) and second is Mysql database to store your joomla sites data.
Next we integrate our EKS cluster with further aws services such ELB , EFS to make to balance the load and make our Deployment's data persistent.These entire things are done using CLI.
For Launching this setup first we need some software:
We have to create the AWS IAM user:
Now we have to configure the AWS account using cli. In my case, I already configure my AWS profile but you can configure using the access key and sercet key which you get when you create AWS IAM user.
Now , firstly we have to create EKS-cluster using the below code:
apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: niscluster region: ap-south-1 nodeGroups: - name: ng1 desiredCapacity: 2 instanceType: t2.micro ssh: publicKeyName: mykey70600 - name: ng2 desiredCapacity: 2 instanceType: t2.micro ssh:
publicKeyName: mykey70600
Create the cluster using this command
eksctl create cluster -f cluster.yml
Now when we create the cluster then instance, security group and cloudFormation is created
Now create a config file by using this config file we can access the EKS cluster from windows CLI.
kubectl config view
aws eks update-kubeconfig — name niscluster
Now we have to create EFS. I use EFS because I need a shared memory(storage) among all the pods.
Before going to the main file creation we have to install one software in all the nodes manually by going inside each EC2 instance.
sudo yum install amazon-efs-utils -y
Now go to the main project means creating the yml files
we have to create kustomization file for deploying the application.
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization secretGenerator: - name: mysql-secret literals: - password=redhat123 - userpass=nishant123 resources: - efs-provisioner.yml - role.yml - storage.yml - deploy-mysql.yml
- - deploy-joomla.yml
First of all we have to create the efs-provisioner.yml file
kind: Deployment apiVersion: apps/v1 metadata: name: efs-provisioner spec: selector: matchLabels: app: efs-provisioner replicas: 1 strategy: type: Recreate template: metadata: labels: app: efs-provisioner spec: containers: - name: efs-provisioner image: quay.io/external_storage/efs-provisioner:v0.1.0 env: - name: FILE_SYSTEM_ID value: fs-1b1399ca - name: AWS_REGION value: ap-south-1 - name: PROVISIONER_NAME value: nis-provisioner/aws-efs volumeMounts: - name: pv-volume mountPath: /persistentvolumes volumes: - name: pv-volume nfs: server: fs-1b1399ca.efs.ap-south-1.amazonaws.com path: /
create this file using
kubectl create -f efs-provisioner.yml
create role.yml - this file provide additional security and power to the provisioner.
apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: nfs-provisioner-role-binding subjects: - kind: ServiceAccount name: default namespace: nisns roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.io
create this file using
kubectl create -f role.yml
create-storage.yml - we create the pvc and storage for making data persistent.
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: aws-efs provisioner: nis-provisioner/aws-efs --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: efs-joomla annotations: volume.beta.kubernetes.io/storage-class: "aws-efs" spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: efs-mysql annotations: volume.beta.kubernetes.io/storage-class: "aws-efs" spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi
create this file using
kubectl create -f storage.yml
Now come on the main file, deploy-mysql.yml - using this file we create mysql database for joomla.
apiVersion: v1 kind: Service metadata: name: joomla-mysql labels: app: joomla spec: ports: - port: 3306 selector: app: joomla tier: mysql clusterIP: None --- apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: name: joomla-mysql labels: app: joomla spec: selector: matchLabels: app: joomla tier: mysql strategy: type: Recreate template: metadata: labels: app: joomla tier: mysql spec: containers: - image: mysql:5.6 name: mysql env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: mysql-secret key: password ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: efs-mysql
create this file using
kubectl create -f deploy-mysql.yml
deploy-joomla.yaml - this creates our main deployment joomla.
apiVersion: v1 kind: Service metadata: name: joomla labels: app: joomla spec: ports: - port: 80 selector: app: joomla tier: frontend type: LoadBalancer --- apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: name: joomla labels: app: joomla spec: selector: matchLabels: app: joomla tier: frontend strategy: type: Recreate template: metadata: labels: app: joomla tier: frontend spec: containers: - image: joomla name: joomla env: - name: JOOMLA_DB_HOST value: joomla-mysql - name: JOOMLA_DB_PASSWORD valueFrom: secretKeyRef: name: mysql-secret key: password ports: - containerPort: 80 name: joomla volumeMounts: - name: joomla-persistent-storage mountPath: /var/www/html volumes: - name: joomla-persistent-storage persistentVolumeClaim: claimName: efs-joomla
create this file using
kubectl create -f deploy-joomla.yml
Now run the kustomization file to build the entire setup
Now wait for sometime until the podsand deployment are not created. After sometime I access the pods.
Joomla successfully deploy Now time to delete all the things
first of all delete kustomization file by typing
kubectl delete -k .
After delete the kustomization file you have to delete EFS
After deleting this we have to delete the cluster
eksctl delete cluster -f cluster.yml
GITHUB URL:
THANK YOU !!!