Wordpress Deployment with Cluster Monitoring on Amazon EKS
This is a task given by Mr. Vimal Daga under EKS Training.
Overview
Deploying Wordpress website on EKS Cluster via fargate profile and using HELM to integrate monitoring tools like Grafana and Prometheus. We will see about the EKS and its uses case how it use and how it configure what will be the processor for creating such kind of cluster and how many type of cluster we can make.After this we will Integrate it with EBS, EFS and ELB.After doing Integration we can launch a pod that will be Wordpress with MySQL .for this site we first have to configure MySQL and then Wordpress. We will then use HELM , the package manager for Kubernetes. Then we can launch a prometheus server on the EKS and then integrate it with Grafana which will provide us with a dashboard to monitor the cluster.
AWS EKS: Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed Kubernetes service, EKS provides a scalable and highly-available control plane that runs across multiple availability zones to eliminate a single point of failure, automatically applies the latest security patches to your cluster control plane, you can also easily migrate any standard Kubernetes application to EKS without needing to refactor your code.
Working: The image below explains its working
Use Cases:
Hybrid Deployment: Run highly available and scalable Kubernetes clusters on AWS, while maintaining full compatibility with your Kubernetes deployments running anywhere else.
Machine Learning: Model your machine learning workflows and efficiently run distributed training jobs using the latest EC2 GPU-powered instance types.
Batch Processing: Using EKS, you can plan, schedule, and execute your batch computing workloads across the full range of AWS compute services and features, such as Amazon EC2, Fargate, and Spot Instances.
Getting started with eksctl: Amazon EKS using eksctl, which is a simple command line utility for creating and managing Kubernetes clusters on Amazon EKS,and the kubectl command line utility will be configured to use your new cluster. eksctl automatically creates several AWS resources for you.
Install the AWS CLI:
- Download the AWS CLI MSI installer for Windows (64-bit) at https://awscli.amazonaws.com/AWSCLIV2.msi
- Run the downloaded MSI installer and follow the onscreen instructions. By default, the AWS CLI installs to C:\Program Files\Amazon\AWSCLIV2.
Configure your AWS CLI credentials: Both eksctl and the AWS CLI require that you have AWS credentials configured in your environment. The aws configure command is the fastest way to set up your AWS CLI installation for general use.
Install eksctl: The GitTag version should be at least 0.22.0. If not, check your terminal output for any installation or upgrade errors, or manually download an archive of the release from https://github.com/weaveworks/eksctl/releases/download/0.22.0/eksctl_Windows_amd64.zip, extract eksctl, and then execute it.
After successful installation, set path in local system by editing environment variables.
Test that your installation was successful with the following command.
eksctl version
Creating Cluster using Spot Instance: AWS spot instances are unused EC2 machines that are available for less than on Demand price.Therefore we can significantly save on our infrastructure costs.
We need to write yml file defining all our requirements for our cluster, mention the no. of nodegroups and define their specifications, we can mention the instance type and desired no. of nodes running inside the group.
For creating a cluster using .yml code, have to create a folder then using “mkdir <folder name> and then enter into folder and create a .yml code
One command to create our cluster:
eksctl create cluster -f <cluster_name.yml>
Creating all yaml files to deploy Wordpress:
Integrating AWS ELB with our cluster: Here, we will use the Load Balancer type service to expose pods because LoadBalancer service uses the ELB behind the scene.
The ELB will provide a public ip using which we can access our pods from anywhere in the world.It will also balance the load among all available pods automatically.
Kubernetes Code to deploy Mysql:
Kubernetes Code to deploy Wordpress:
Also made other files
Used the kustomization concept to run all the files in a predefined sequence with the command “kubectl create -k .â€
The output is here:
Creating Fargate Cluster: AWS fargate is serverless compute engineer for container that works with both ECS and EKS .Fargate makes it easy for you to focus on building our application.
Here,we can know the max pods can create of this instance type.
CNI(Container Network Interference): Container Network Interference is plugin , which allow kubernetes pods to receive native AWS Vpc ip address.
Amazon EKS supports native VPC networking via the Amazon VPC Container Network Interface (CNI) plugin for Kubernetes. Using this CNI plugin allows Kubernetes pods to have the same IP address inside the pod as they do on the VPC network. This CNI plugin is an open-source project that is maintained on GitHub. The Amazon VPC CNI plugin is fully supported for use on Amazon EKS and self-managed Kubernetes clusters on AWS.
ENI(Elastic Network Interference): An Elastic Network Interference is a logical networking component in a vpc that represents a virtual network card. it can include the following attributes. a primary private ipv4 address from ipv4 range of our vpc.
EFS (Elastic File Storage): Create an Amazon EFS file system to store your files in the Amazon cloud. A file system grows and shrinks automatically with the files you put in, and you pay only for what you use
Scalable,Elastic fully managed cloud native NFS file system.
Helm: The package manager for Kubernetes
Helm is the best way to find, share, and use software built for Kubernetes.Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.
Charts are easy to create, version, share, and publish — so start using Helm and stop the copy-and-paste.
Helm is a graduated project in the CNCF and is maintained by the Helm community.
Install helm.exe application into the system
Initialize helm for the first time when use
Creating NameSpace: Namespaces provide a scope for names. Names of resources need to be unique within a namespace, but not across namespaces. Namespaces can not be nested inside one another and each Kubernetes resource can only be in one namespace.
We can create a new namespace for our cluster using
“kubectl create namespace <namespace name>
Creating service account in tiller:
# kubectl -n kube-system create serviceaccount tiller # kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
# helm init --service-account tiller
Installation of prometheus using helm:
Allowing port 80 to run prometheus on browser
Installation of Grafana using helm:
Selecting Prometheus as a Data Source
Importing Dashboard for monitoring
Here's the Dashboard:
Now its done, this is the prove that we can launch our Prometheus with Grafana. Now everything is at its place now we can use this kind of setup to do some great things.
At last we must delete our cluster, because EKS is not a free service provided by AWS.
That's it.
Thanks a lot for reading : )
WebDev | GameDev | Cloud
4 å¹´Awesome ????
Python | Pandas | Numpy | Seaborn | Matplotlib | Advance SQL | Tableau | Statistical Analysis | Machine Learning
4 å¹´Nice work ????