Amazon EKS-Project

Amazon EKS-Project

HELLO! Everyone I am succesfully completed my EKS task given by the Mr vimal daga sir

In this task I deploy wordpress and MySQLon the top of Amazon EKS

No alt text provided for this image

What is Amazon EKS?

Amazon EKS (Elastic Container Service for Kubernetes) is a managed Kubernetes service that allows you to run Kubernetes on AWS without the hassle of managing the Kubernetes control plane.

The big benefit of EKS, and other similar hosted Kubernetes services, is taking away the operational burden involved in running this control plane. You deploy cluster worker nodes using defined AMIs and with the help of CloudFormation, and EKS will provision, scale and manage the Kubernetes control plane for you to ensure high availability, security and scalability.

Before you start

You will need to make sure you have the following components installed and set up before you start with Amazon EKS:

  • AWS CLI – while you can use the AWS Console to create a cluster in EKS, the AWS CLI is easier.
  • Kubectl – used for communicating with the cluster API server.
  • eksctl - eksctl is a simple CLI tool for creating clusters on EKS - Amazon's new managed Kubernetes service for EC2. It is written in Go, uses CloudFormation, was created by Weaveworks and it welcomes contributions from the community. 

STEP 1 Creating an user :

I already created a user . we can see that....

No alt text provided for this image

And i also configure with CLI

No alt text provided for this image

Now move on the task .......

Setup of cluster :

To setup the kubernates cluster using Amazon EKS . I am going to create a yml code because Kubernates support YML formate only and also attached a key which is helpful for login inside the node

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: mycluster
  region: ap-south-1
nodeGroups:
 - name: ng1
   desiredCapacity: 2
   instanceType: t2.micro
   ssh:
      publicKeyName: key 
  
 - name: ng2
   desiredCapacity: 1
   instanceType: t2.micro
   ssh:
      publicKeyName: key 

To run this file i use the eksctl command....

eksctl create cluster -f cluster .yml

No alt text provided for this image
No alt text provided for this image

Here we can see that the cluster is created ....

we can also see in AWS Dasboard..

No alt text provided for this image

And also create the nodes in Amazon EC2 Service section...

No alt text provided for this image

Now we need to configure the kubectl ,which is client for the kubernates API. For this I use a command

aws eks update-kubeconfig --name mycluster

kubectl config view : to see the kubectl is configured or not.

No alt text provided for this image
No alt text provided for this image

STEP 2 :Setup of Wordpress and MySQL:

Firstly I am going to create a yml code for secret that will contain all the critical data like username and password


apiVersion: v1 kind: Secret metadata:   name: mysecure data:   rootpass: cmVkaGF0   userpass: cmVkaGF0

To run this file i use a command ....

kubectl create -f dbsecret.yml

No alt text provided for this image

MySQL:

MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL).

SQL is the most popular language for adding, accessing and managing content in a database. It is most noted for its quick processing, proven reliability, ease and flexibility of use. MySQL is an essential part of almost every open source PHP application. Good examples for PHP & MySQL-based scripts are WordPressJoomlaMagento and Drupal.

Here i am going to create a deployment for MySQL for this i will create a service ,PVC and deployment for MySQL

apiVersion: v1
kind: Service
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
spec:
  ports:
    - port: 3306
  selector:
    app: wordpress
    tier: mysql
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name:  wordpress-mysql
  labels:
    app:  wordpress
spec:
  selector:
    matchLabels:
      app: wordpress
      tier: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: mysql
    spec:
      containers:
      - image: mysql:5.6
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysecure
              key: rootpass
        - name: MYSQL_USER
          value: suhaib
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysecure
              key: userpass
        - name: MYSQL_DATABASE
          value: sqldb
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
	


To run this file

kubectl create -f mysql.yml

and we also check the pod is running or not

kubectl get pods

No alt text provided for this image

Wordpress:

WordPress is a free and open-source content management system (CMS) written in PHP and paired with a MySQL or MariaDB database.

Here I am going to create a deployment for Wordpress for this I will create a service ,PVC and deployment for Wordpress

apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
    - port: 80
  selector:
    app: wordpress
    tier: mysql
  type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: go-pv-claim
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  selector:
    matchLabels:
      app:  wordpress
      tier: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: mysql
    spec:
      containers:
      - image: wordpress:4.8-apache
        name: wordpress
        env:
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql
        - name: WORDPRESS_DB_USER
          value: suhaib
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysecure
              key: userpass
        - name: WORDPRESS_DB_NAME
          value: sqldb
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
      volumes:
      - name:  wordpress-persistent-storage
        persistentVolumeClaim:
          claimName: go-pv-claim

To run this file ...

kubectl create -f wordpress.yml

and also see the pods

kubectl get pods

kubectl get all : to see all the details

No alt text provided for this image

here we can see that the Two persistent storage is created....

No alt text provided for this image

Loadbalancer is also created...

No alt text provided for this image

Now we can access the Wordpress using the EXTERNAL-IP ( In Above snapshot 3rd snapshot we can see the external-ip )

And we also use the DNS name to access the Wordpress beacuse both are same

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

I have done with all the setup.

We can delete the cluster using command ....

eksctl delete cluster -f cluster .yml

No alt text provided for this image

Thank you for reading my article......................































To view or add a comment, sign in

More articles by Suhaib Ansari

  • Task 4 : Deploy Wordpress(public) and MySQL (private)

    Hello! Everyone I am completed task 4 given by Mr Vimal Daga Sir Performing the following steps: 1. Write an…

    2 Comments
  • Terraform Project Task 2

    Here I have done Task 2 given by Mr vimal Daga sir Have to create/launch Application using Terraform Create the key and…

    7 Comments
  • HYBRID CLOUD COMPUTING PROJECT

    Here I have done first task given by Mr vimal Daga sir -----------------My Task…

    14 Comments

Others also viewed

Explore content categories