Amazon EKS-Managed Kubernetes Service

What is 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 stand up or maintain your own Kubernetes control plane. Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications.

For connecting to aws EKS we have following ways such as webUI , CLI and terraform code also. Here we are using CLI but for connecting to aws EKS using CLI we required secret key and access key and CLI also have two ways to connect to EKS. we wil do this with CLI

Install AWS CLI version 2

Create IAM user with AdministratorAccess power

Configure AWS CLI

Configure aws cli using access key (like a username ) and secret key(password) of user we have just created.

Install EKSCTL CLI TOOL

eksctl is a simple CLI tool for creating clusters on EKS - Amazon's new managed Kubernetes service for EC2 . why we need EKSCTL tool ? if we have aws cli beacause aws CLI have very less functionalities and also downlod the kubectl cli tool help in managing cluster and add path of both to you system veriable.

GitHub Link: https://github.com/rohitraut3366/EKS.git

Creating EKS cluster

Creating YML file

To create cluster using above file run the command : eksctl create cluster -f file.yml

Behind the scene this eksctl communicate by picking aws configure in your cli to get the access of aws account and CloudFormation to create cluster. as it create the cluster it lauches slave nodes using aws EC2 service

Ganerate kubeconfig file so we can communicate with the cluster using kubectl for this run the following command

Testing Kubernetes Cluster

Launching pod using kubectl using container image which have simple webpage.

Expose image to outside world using service of Kubernetes called load balancer.

Now we are going to create one deployment, scale it and also expose the deployment to the outside world with service type load balancer at port no 80 . behind the scene kubernetes creating load balancer this load balancer have unique host name so we can access out website. Copy this hostname and paste it in URL section of your browser you will see the website.

As we have scaled deployment to 3 replicas. May be this 3 replicas running on different node internally load balancer do its load balancing and send client request to each node so if you refresh your page you will see different ip address.if you dont see try to use incognito tab beacuse when we load some website in browser it store cache of it.

PVC

Task : Do this to understand why need PVC

Create one deployment as we did having same image which contain same webpage as we seen having only one replica and create one webpage having name index.php and write some code. To copy this code to you node using kubectl.

kubectl cp index.php podname:/var/www/html

Expose the pod using load balancer as we did above we will see our new page in browser using host name of load balancer.

If you delete this pod replica set recreate this pod having older page. so we lost our new page to make it permanent we need PVC or any centralized storage.

To create PVC:

When we create the pvc it request the storage to pv and pv takes the storage from storage class but it eks this storage class is connected to EBS and it pick the storage from EBS.

cmd : kubectl create -f pvc.yml

when you create this pvc is in pending state. In EKS this pvc stays in pending state until it did not attached to any pod. after attching pv and storage class created and if you see volume in EC2 dashboard 10GB EBS volume is created.

Attach PVC to pod

run the edit command and add this content in red box to you deployment file and save it.if you do some mistakes while write this code it reopen notepad file.

After attaching PVC to pod volume automatically created.

Launching MYSQL and wordpress on Cluster using Kustomization.yaml.

For files GitHub link is provided at bottom of article

HELM

HELM is like a package management tool which manage kubernetes application called Charts.

To begin working with Helm, run the ‘helm init’ command:

heml init

This will install Tiller to your running Kubernetes cluster. It will also set up any necessary local configuration and add stable repositories

It required some addition role/permission

here we are creating serviceaccount in kube-system namespace and give it role of cluster-admin

Now you can install any chart from heml hub

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company.

Grafana

Grafana is open source visualization and analytics software. It allows you to query, visualize, alert on, and explore your metrics no matter where they are stored. it provides you with tools to turn your time-series database (TSDB) data into beautiful graphs and visualizations. Attaching it to Prometheus.

Add the Prometheus server as a data source. We need to create dashboard for monitoring the Kubernetes cluster.

Link : https://grafana.com/grafana/dashboards/10000

EKS Fargate Cluster

AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service(ECS)and Amazon Elastic Kubernetes Serivce (EKS). Fargate makes it easy for you to focus on building your applications. 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.

Fargate allocates the right amount of compute, eliminating the need to choose instances and scale cluster capacity. wew only need to pay for the resources required to run containers, so there is no paying for additional servers.

EkS fargate is available in limited region so check the availability from their documentations. (https://docs.aws.amazon.com/eks/latest/userguide/fargate.html)

For each pod it create One Node

Code:

GitHub Link : https://github.com/rohitraut3366/EKS.git

Linked In profile : https://www.linkedin.com/in/rohit-raut-71b8a119a/

Thanks for reading…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store