NOTE:- Me(Hirendra kumar) and my friend(Mukul jeverya) did this task together because of some laptop performance problem.
Let’s start -
Deploying drupal On Amazon EKS using EFS as a storage -
Amazon Elastic Kubernetes Service :-
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. AWS makes it easy to run Kubernetes in the cloud with scalable and highly-available virtual machine infrastructure, community-backed service integrations, and Amazon Elastic Kubernetes Service (EKS), a certified conformant, managed Kubernetes service.
Amazon Elastic File System :-
Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system for use with AWS Cloud services and on-premises resources. It is built to scale on demand to petabytes without disrupting applications, growing and shrinking automatically as you add and remove files, eliminating the need to provision and manage capacity to accommodate growth.
What is Drupal?
Drupal is a content management software. It’s used to make many of the websites and applications you use every day. Drupal has great standard features, like easy content authoring, reliable performance, and excellent security. The Drupal project is open source software. Anyone can download, use, work on, and share it with others. It’s built on principles like collaboration, globalism, and innovation. It’s distributed under the terms of the GNU General Public License (GPL). There are no licensing fees, ever. Drupal will always be free.
what is MySQL?
MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is developed, marketed and supported by MySQL AB. It is released under an open-source license. So you have nothing to pay to use it. It is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages.
few pre-requisite for this -
You should have pre created IAM user. Identity and Access Management (IAM) user is an entity that the root user create in AWS to represent the person or application that uses it to interact with AWS.
> To create IAM user simply go to IAM service and create a user with some password. we can control this user our own way . we can give limited power so that someone use this then they don’t have all power to do. but in some use case we can give this user admin power .
Installation of EKSCTL-
Eksctl is a tool , using this we can create whole cluster on EKS in one go .
> eksctl create cluster -f filename.yml
using from CLI-
> we can run this from webUI , CLI and also using code file using terraform. here we are using CLI . for this first we have to login to our aws account using IAM user which we have created earlier. we login from CLI with downloaded credentials.
> using “aws configure” command we can set access key and secret key to login.
Now creating EKS cluster —
Create a YML file for cluster configuration . In this code file we are creating two nodegroups . In one nodegroup we creating two instances with t2.micro and in another nodegroup , we created one nodegroup of t2.small. and provided public key for doing ssh to that instances.
for creating the cluster use this command-
eksctl create cluser -f cluster.yml
> cluster created successfully with the name mycluster .
> we can see it from CLI also.
> we can see the launched instacnes from EC2 console also because behind the scene EKS contacts the ec2 service and lauched instances that is created in cluster.
seeing lauched instances or Nodes from CLI.
update the kubeconfig file:-
This is done so that the kubectl gets configured and we can easily connect to the EKS cluster.
use command —
eks aws update-kuebconfig --name mycluster
Cloudformation -
In AWS Cloudformation is a program which helps us to perform things automatically. So eksctl also internally uses cloudformation for cluster creation. Therefore after creation of cluster various stacks are also created under cloudformation.
> eksctl also create some security group and VPC also.
Creating Namespaces -
Namespace is like a room in which one team can work separately from anther teams. Namespaces are considered as workspace.
command for creating namespace -
kubectl create ns namespace_name
we created a new namespace called hirendra. you can see all namespaces using kubectl get ns .
seeing all the namespaces-
Update the default namespace -
> kubectl config set-context --current --namespace=hirendra
creating EFS storage -
Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system for use with AWS Cloud services and on-premises resources. It is built to scale on demand to petabytes without disrupting applications, growing and shrinking automatically as you add and remove files, eliminating the need to provision and manage capacity to accommodate growth.
we created EFS manually . Important thing while creating, we have to create in the same VPC and in same subnets in which nodes are running so simply go and check the EC2 instances then select the desired one then create.
we created EFS with same VPC and security group.
creating EFS-PROVISIONER -
The efs-provisioner allows us to mount EFS storage as PersistentVolumes in kubernetes. It consists of a container that has access to an AWS EFS resource. The container reads a configmap which contains the EFS filesystem ID, the AWS region and the name we want to use for our efs-provisioner.
we create yml file code for EFS-PROVISIONER. In this file in place of server we need to write the DNS name from the efs file we created and also change the file system id accordingly.
create the nfs-provisioner-role-binding-
RBAC stands for role based access control.This provides roles or permissions .
creating the storage class and two pvc , one for drupal and One for MySQL:-
MySql Deployment:
This code is for creating a sql database . Here a service named clusterIP is also created which is a part of AWS ELB. We provide all the information in this file for creation of a pod like its name, its image, volume claim etc.
creating drupal deployment -
This code is to create drupal deployement and a service named loadbalancer which is again a part of AWS ELB. load balancer manages the traffic on the websites .
creating kustomization file-
Now after we write all these codes , we need to execute them in a particular order to run them properly and for this reason we need to create the following file.We just need to specify all the above files in a particular order in its code and run it and it will create everything.
creating secret file for privacy of our database and drupal env variable in which we put our password and other credentials things.\
creaitng all the files using kustomization file-
we need to run only one command and all files will be created . command is-
kubectl create -k . -n namespace
using above command all the file will be created . now we can see that our drupal deployment and MySQL deployment is creating.
now load balancer is created automatically-
using the DNS name we can access our drupal website that is launched-
Now it is completed.
For getting the code file please visit-
THANK YOU !!!