Building A Kubernetes App With Amazon EKS and Learning EKS with deploying hands on INDUSTRIAL example

DEPLOYING WORDPRESS AND MYSQL ON AWS EKS

Aman Miglani
6 min readJul 17, 2020

Its common knowledge that Amazon Web Services(AWS) is a well-known provider of cloud services, while Kubernetes is quickly becoming the standard way to manage application containers in the production environment. While many developers would gladly use Kubernetes, the time-consuming cluster management process can be a turnoff. As a solution, developers can use Amazon Elastic Container Service for Kubernetes (Amazon EKS), which allows them to create Kubernetes clusters in the cloud very quickly and easily.

Let’s take a look at the topics covered in this article:

  1. .What is AWS EKS and its benefit
  2. How does Amazon EKS work?
  3. Build Kubernetes Cluster with yml file
  4. Build a Kubernetes app with Amazon EKS

AMAZON EKS:

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.

Benefits

  1. High Availability : EKS runs the Kubernetes management infrastructure across multiple AWS Availability Zones, automatically detects and replaces unhealthy control plane nodes, and provides on-demand, zero downtime upgrades and patching.
  2. Secure : EKS automatically applies the latest security patches to your cluster control plane. AWS also works closely with the community to ensure critical security issues are addressed before new releases and patches are deployed to existing clusters.
  3. Built with the Community: EKS runs upstream Kubernetes and is certified Kubernetes conformant, so applications managed by EKS are fully compatible with applications managed by any standard Kubernetes environment. AWS actively works with the Kubernetes community, including making contributions to the Kubernetes code base that help you take advantage of AWS services and features.
  4. Serverless option: (the easiest way tp deploy k8’s custer) EKS supports AWS Fargate to provide 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

How it works:

Get Started with Amazon EKS -There are 2 ways to create Kubernet groups with labor nodes in Amazon EFS:

  1. Start with the Eksctl command. (Download Ekctl)
  2. Get started with the AWS Management Console. (Download Awscli)

PreRequisities Needed Before creating cluster :

1: We have to configure aws in cli.

2: Weh ave to admin power IAm user for simplicity

3: configure it on cli

4: We have to dwnload a program called Eksctl program through which we can create cluster from cli

Build Kubernetes Cluster using yml file:

In this file we just have to tell how much Node group and in each Node group no. of instance we want and of what type .

After creating this file we just have to run a command and this deply our cluster on aws.

C: eksctl create cluster -f cluster.yml

Note that this may take 15–20 minutes.

After this update the cluster config by runing a simple command

c: aws eks update-kubeonfig — name “clustename”

To see cluster on aws

C: eksctl get cluster

Build a Kubernetes app with Amazon EKS:

What we need? .

We have to create 4 files :

  1. Wordpress.yaml
  2. sql.yaml
  3. secrets.yaml
  4. kustomization.yaml

1.Creating Wordpress.yaml:

IN this we are creating SERVICE type called Load Balancer which will use the elb of aws behind the scene so that pods can be expose to public world.

I a have used A persistentvolume so that we not lose data.
bcz Data is imp for us a company prospective

Using the url of L.B we can see the worpdpress sight when the pod will creatd on cluster.

NOW in the same file we have to give the all the spec of pod we want to deploy on k8’s cluster .Here i m giving the configuration of wordpress pods .In this i have given the passwrd in a “secret file” so that no other can able to see my passwrd which is good as security prospective.

2.NOW similarly creating Mysql-Pods and giving configuration

IN this we are creating SERVICE type called CLUSTERIP bcz we dont our mysql pod to expose to public world .We only want that only our wordpress sql can access .

Also creating a persistentvolme for this pods also bcz as if contiane get terminated but we wont lose any data .Bcz client data is imp for us

now giving the configuration of mysql- pods and also mounting pvc to pods folder which store all the data

3. Crearting Secret.yml file which will have pswrd

4.Creating the kustomization.yaml file

This file declares the customization provided by the kustomize program.

NOW as these file created U have to run only a simple command
C: kubectl create -k .
This will create the whole setup for us in just one click

NOw u can see all the pods and service are created
and if u want to see the public DNS of wordpress thorough which u can connect is
C: kubectl get all

By this u will get all the services running and elb DNS

NOw after click on install and giving passwrd u will login to Dashboard of wordpress

And finally the goal of making this task has been acheived. The final objective of task been completed by launching wordpress-mysql on pod

IN last one main POINT is creating the cluster on aws wil charge u per hour 0.1$ so after practicisng u have to delete cluster
NOW to if have delploy the cluster from aws console then delete it from aws console
and if u have created the clsuter from cli using cli than u have to delete by running a simple command
C: eksctl delelte cluster -f cluster.yml

#keep-learing

#right-education

#keepmotivation
#makeinINDAI FUTURE ready

--

--

No responses yet