Today's Offer - AWS Certification Training - Enroll at Flat 10% Off.

- AWS Blogs -

How To Use Amazon EKS And Deploy A Kubernetes Application With It?

Today everyone knows that Amazon Web Services(AWS) is a leading global provider of cloud services, and Kubernetes is gaining attention as a powerful tool to deploy and maintain containers in production environments. Many people love to use Kubernetes, but the hard part of cluster management can be a drawback to it, to cater to this issue we have the solution in the form of Amazon EKS (Amazon Elastic Kubernetes Service ) which helps in making Kubernetes clusters in a fast and easy way.

Many big companies like AWS, Oracle, Microsoft, VMware have been linked to CNCF and adopted the use of Kubernetes, and this has led to a rise in its use and popularity exponentially.

Although the latest versions of Kubernetes made the deployment of clusters an easy process there are still some challenges to its widespread popularity. Although you could get used to with the use of pods, containers, services and replication controllers, concepts like networking, load balancing, and monitoring are a big challenge to understand and manage.

What is Amazon EKS?

As we know that containers were always there, we call them Docker in the current time. Amazon Elastic Kubernetes Service has simplified the use of Kubernetes on AWS/Cloud hence removing the effort of setting it up on a personal control-plane. It takes care of upgrades & patching.

EKS - Cloud Trail are together used to track user and cluster activity.  Cloud Trail captures the API calls coming to EKS.

Logs for K8s can be seen in Amazon CloudWatch.

Running clusters can be updated without removing old clusters or creating new clusters. It offers compatibility with add-ons like CoreDNS used to create DNS service, web-based UI called Kubernetes Dashboard and kubectl a utility used to access and manage clusters. Control plane in K8s knows how talking happens between K8s and cluster:

  • Start-stopcontainers
  • Schedulingofcontainers.
  • Checkinghealthofcontainers
  • Managingdifferenttasksrelatedtocontainers.

Benefits of EKS 

  • EKSisuseful in running K8s infrastructure in different AZ, hence engineers do not have to worry about the control plane.
  • Further security is added with the communication channel being encrypted.
  • AWS and K8s community also work together for upgrading codebase.
  • EKS - K8s applications are compatible.
  • Worker nodes are deployed using the AMIs and Cloud Formation.

What is Kubernetes?

It is a software using which we can perform deployment and management of containers. Kubernetes provides features like scalability using which we can extend containers as we want.

But, it also has some drawbacks such as too much time is consumed in cluster deployment using master and worker nodes. The solution to this is Amazon EKS.

K8s word is a Greek word, which means a pilot. It was open-sourced in 2014. It is built upon google long term experience. Containers help to bundle and run code. We need to control containers that have applications in them. If a container crashes another container takes its place. This thing can be controlled as well. K8s is the answer to this.

Benefits like scaling containers are provided using this.

Use of Kubernetes? 

  • Load Balancing: Containers can be exposed using DNS and IP address. The load balancer shares the traffic going to containers.
  • Storage orchestration: It helps to mount a storage system, such as local storage, public cloud providers.
  • Cost Reductions: Containers share OS and Network of the Host machine. This comes under resource utilization as compared to create a VM. They are light in weight and use fewer resources hence cost-efficient.
  • Easy to use: Containers help to run the same application across clouds.
  • Global support: K8s popularity is so high that it is considered best among all orchestration tools. It has many active developers. Many market leaders have adopted to K8s. 

How Amazon EKS works?

Let us understand the working of EKS using below steps. Trust me they are easy :)

Read: How to Build a Career in AWS?
  • Create an Amazon EKS cluster using – AWS Console, AWS CLI or AWS SDK.
  • Setup a few worker nodes. Make sure they can communicate with the Amazon EKS cluster.
  • Kubectl – configure it on cluster so that you can talk to your cluster.

Demo: Nginx Deployment

Let’s deploy an Nginx application on Kubernetes with the help of Amazon EKS.

1). AWS IAM service role and a VPC

Create an IAM role for Kubernetes to use AWS resources

  • Go to AWS IAM Console >> Roles >> Create role
  • AWS service >> EKS as the service
  • Name of the role >> Create a role

Create a Virtual Private Cloud (VPC) for cluster deployment.

  • AWS CloudFormation console >> Create Stack.
  • Specify Template >> Amazon S3 URL, paste the below URL

URL: https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-10-08/amazon-eks-vpc-sample.yaml

  • Enter details >> Create

2). Create an Amazon EKS cluster 

  • Amazon EKS >> Create Cluster [ Select the Role we created in IAM]

3). Setup Kubectl

Kubectl is a utility used to talk to clusters.

kubectl package comes in built-in most of OS packages hence easy in installation.

You can use the link to download and install kubectl.

Have the latest version of the AWS CLI installed?

Configure Kubectl to talk to your cluster

  1. Configure a user that can access to this cluster. 

4). Launch and configure Amazon EKS worker nodes

Read: What Is AWS Lambda? AWS Lambda Tutorial for AWS Solution Architects

Launch worker nodes only when the cluster is ACTIVE. Launching them before the cluster is up will not allow them to register with the cluster. Let’s join worker nodes to K8s cluster by the below steps:

  • Go to AWS Cloud Formation console >> Create stack

URL : https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-10-08/amazon-eks-nodegroup.yaml 

 Press Next

On Next page, press Next

  • When stack is completed, in the “Output” section of the stack. Make a note of Role ARN 

Let’s join worker nodes to Kubernetes cluster by below steps:

  • Create a file named aws-auth-cm.yamland use the below data. Replace the AWS-ARN with the node instance role that you copied from the stack output earlier. 
  • Apply the changes in this file.

kubectl apply –f aws-auth-cm.yaml  

  • Once done check the status of worker nodes. They should be in Readystate

kubectl get nodes 

Nodes should be visible in Ready state.

5). Launch a simple Nginx application

  • Create a Kubernetes object - type

Create a file nginx.yaml and populate the details below: 

  • Create a Kubernetes object of Service type. Service tells us about the logical set of Pods.

 Create a file nginx-svc.yaml and populate details below: 

Read: Difference Between Google Cloud, AWS & Microsoft Azure Cloud
  • Deploy the Nginx application

kubectl create –f nginx.yaml

  • Deploy the Nginx service

kubectl create –f nginx-svc.yaml

  • Find running service, ports and external ip.

kubectl get services –o wide

kubectl describe svc nginx  ## LoadBalancer Ingress will be the ip to get the landing page of Nginx.

  • Try to open the Nginx application using the this IP and port. 

Useful Kubernetes tools.

Finally – some cherry on the cake.

Some useful tools used with Kubernetes.

Kube Cluster Deployment Tools

  • Kubespray
  • Minikube
  • Kubeadm
  • Kops
  • Kubernetes on AWS (Kube-AWS)

Monitoring Tools

  1. Kubebox
  2. Kubetail
  3. Kubewatch
  4. Prometheus
  5. Searchlight
  6. cAdvisor
  7. Sumo Logic App
  8. Dynatrace

Testing

  1. Kube-monkey
  2. Test-infra
  3. Sonobuoy

Security

  1. Trireme
  2. Aporeto
  3. Twistlock
  4. Falco
  5. io

Helpful CLI Tools

  1. Cabin
  2. Kubectx/Kubens
  3. Kube-shell
  4. Kail

With this write-up, you have learned fundamentals of Amazon EKS and some amazing practices of it. If you have any further queries related to it then drop your query in the comment below. Happy learning!

Read: Top 70 AWS Interview Questions and Answers

    Ish Kumar Kapila

    A DevOps Engineer by profession and a Technical Blogger by passion. I love to learn anything about DevOps and Cloud computing and at the same time share the knowledge among those who are willing to learn and share the same passion with me.


Trending Courses

AWS

  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

4 days 24 Nov 2019

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

5 days 25 Nov 2019

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

5 days 25 Nov 2019

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

6 days 26 Nov 2019

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

14 days 04 Dec 2019

Course for testing

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

34 days 24 Dec 2019

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

13 days 03 Dec 2019

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

5 days 25 Nov 2019

SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

8 days 28 Nov 2019

Comments

Search Posts

Reset

Receive Latest Materials and Offers on AWS Course

Interviews