AWS EKS

Getting Started with AWS EKS

AWS EKS (Amazon Elastic Kubernetes Service) is a managed service that enables you to run Kubernetes on AWS without your own Kubernetes control plane. Let’s have a quick introduction to Amazon EKS!

The widespread adoption of cloud computing and the positive interventions of technologies such as containers have revised application development norms. Now, enterprises could host infrastructure on public cloud platforms such as AWS and use container orchestration tools such as Kubernetes.

These technologies continue to bring new flexibility for enterprises worldwide. However, the use of Kubernetes comes with highly time-consuming cluster management processes, which may not be favorable for certain developers. Therefore, AWS EKS or Elastic Kubernetes Service is the perfect solution for addressing the setbacks of excessive time consumption in using Kubernetes for cluster management.

Try Now: AWS Certified DevOps Professional Free Test

EKS allows developers to utilize AWS functionalities for easier and faster creation of Kubernetes clusters in the cloud. So, is this AWS Kubernetes service reliable? There is only one way to find out! Let us reflect on the definition of Amazon’s EKS, its history and architecture, and some of its prominent features.

In addition, the following discussion would also point out a detailed outline of the working of EKS and its benefits. Readers could also find a demo for getting started with EKS outlining steps for deploying a Kubernetes application with EKS.

What is AWS EKS?

Prior to a definition of Amazon EKS, let us reflect on the definition of Kubernetes first. Kubernetes is the open-source tool for deployment and management of containerized applications such as batch processing workers, microservices, and PaaS solutions.

Development teams can use Kubernetes for the management of many functions such as monitoring and controlling resource consumption, load balancing, limit over resource consumption, or using additional resources from new hosts added in a cluster.

You can also use Kubernetes for managing other important workflows, thereby establishing its credibility as a container orchestration tool. Amazon EKS is the best way to use Kubernetes on AWS. EKS is the managed service that helps you run Kubernetes on AWS easily.

Enterprise could use EKS for running Kubernetes without installation and operation of Kubernetes separately. Basically, EKS is available as a fully managed containers-as-a-service (CaaS) solution for simpler Kubernetes deployment on AWS.

History of EKS

According to data by the Cloud Native Computing Foundation, many organizations running Kubernetes use AWS Cloud platform. Kubernetes was an integral component of the IT strategies of such customers of AWS. Therefore, AWS made Amazon EKS available to customers in June 2018 to address the issue of customers in running Kubernetes on AWS. With EKS, AWS customers don’t have to set up Kubernetes clusters from the basic steps.

Prior to AWS EKS, enterprises operating Kubernetes clusters with higher availability had to depend on specialized expertise and formidable dedication in the processes of cluster management. For example, enterprises had to ensure provisioning for K8s management infrastructure on different Availability Zones (AZs).

However, EKS has completely resolved such concerns with the delivery of a production-ready architecture. The architecture of EKS is capable of automatically running and managing Kubernetes clusters throughout different AZs.

EKS Architecture

The next critical aspect to understand before getting started with EKS is the AWS EKS architecture. The architecture of EKS can provide detailed insights to understand how it works and its various features. As a matter of fact, the architecture of AWS EKS is one of the mandatory elements in any introductory guide for getting started with EKS.

Amazon EKS Architecture
Image Source: https://aws.amazon.com/quickstart/architecture/amazon-eks/

You can find two major components in every EKS cluster, such as the control plane and the worker nodes. Let us find out the role of these two components in the operations of EKS.

  • Control Plane

The Control Plane in EKS contains three Kubernetes master nodes running in three distinct Availability Zones (AZs). All the incoming traffic for the Kubernetes API comes through the Network Load Balancer (NLB). The control plane operates on a virtual private cloud under Amazon’s control. Therefore, AWS takes over full management of the control plane, and enterprises cannot manage it directly.

  • Worker Nodes

The second important component of AWS EKS refers to the worker nodes. The worker nodes are basically the EC2 instances running in the virtual private cloud under the organization’s control. As a matter of fact, any AWS instance could qualify as a worker node. Users could access worker nodes through SSH or ensure their provisioning without any automation.

How Does EKS Work?

Therefore, the AWS EKS architecture shows us that the cluster of worker nodes is responsible for running the containers of an organization. On the other hand, the control plane is responsible for the management and monitoring of the source and time of starting the containers.

The flexibility in the architecture of EKS enables organizations to deploy a Kubernetes cluster for every application individually. Enterprises could also utilize an EKS cluster for running multiple applications through AWS IAM configurations and Kubernetes namespaces.

The architecture of EKS also shows the flexibility of provisioning worker nodes through a single command in the CLI, EKS console, or API. On the other hand, AWS takes care of provisioning, scalability, and management of control plane with optimum security. Therefore, EKS takes away the burden of running Kubernetes operations and infrastructure management.

Preparing for the AWS Certified DevOps Engineer Professional exam? Follow this comprehensive guide for the AWS DevOps Engineer Professional exam preparation and get ready to pass the exam.

Features of EKS

The next critical aspect of our discussion on AWS EKS should reflect on its features. The features of EKS can help you understand its functionalities thoroughly and gain a basic impression of its benefits. Basically, you can find that EKS can help you get the reliability, scale, performance, and availability of the AWS platform.

In addition, the integration with AWS security and networking services improve the adoption of EKS across enterprises profoundly. Here are some of the notable features of EKS that can help you ascertain its benefits clearly.

  •  Managed Control Plane

The managed control plane is the foremost striking feature of AWS EKS. EKS provides automatic management of the scalability and availability of Kubernetes API services and etcdpersistence layer for all clusters. Operation of K8s control plane across three AZs helps in ensuring higher availability alongside the detection and replacement of faulty masters.

  • Managed Worker Nodes

The managed worker nodes are also a crucial feature of EKS. You can create, update, or ensure termination of worker nodes with a single command on EKS. The latest optimized Amazon Machine Images (AMIs) help managed node groups in running the nodes. The management process can be carried out alongside the draining of nodes by terminations and updates.

  • Launch with the Simple eksctl Command

The open-source command eksctl can help in getting EKS up and running within a short period of time. Upon execution of the eksctl create cluster command, you get an EKS cluster created and ready for running applications.

  • Security

The advanced features, partner solutions in the larger AWS landscape, and integrations in AWS EKS promote better opportunities for the security of Kubernetes clusters on AWS.

  • Service Discovery

With EKS, you can get the functionalities of Cloud Map on AWS for cloud resource discovery. Enterprises could define the names of application resources and maintain updated locations for dynamic resources. As a result, application availability increases due to the discovery of most updated resource locations by an organization’s web service.

In addition, you can also find an open-source connector with EKS for auto-propagation of internal service registry locations with the launch of K8s services. The connector also removes internal service registry locations upon the termination of K8s services. Cloud Map offers a unified service registry for container workloads, thereby allowing the discovery of K8s-based services.

  • Service Mesh

AWS App Mesh provides reliable functionality in the standardization of the communication between microservices in an application. As a result, you can build and run complex microservices-based applications easily with better speed. App Mesh also ensures simplifying the configuration as part of an application with higher availability and better end-to-end visibility.

  • Comprehensive Use of VPC

The EKS clusters run on Amazon VPC, thereby allowing you to use VPC security groups and network ACLs. The clusters you have wouldn’t share compute resources with other orgs. As a result, you can achieve higher isolation with AWS EKS thereby providing the desired support for building reliable and highly secure applications.

  • IAM Benefits

The integration of Kubernetes RBAC with IAM Authenticator by using Amazon EKS is also helpful for improving granular access controls for K8s masters. In addition, EKS also helps in the easy assignment of IAM permission to service accounts. The IAM role can control access to containerized services, third-party apps, and AWS resources external to the cluster.

In addition to the above-mentioned features, AWS EKS offers many other benefits with its exceptional features. For example, you can add Windows nodes as worker nodes and schedule Windows containers with EKS. The support for load balancing and the use of AWS CloudTrail for logging and monitoring user and cluster activity history is also crucial features of EKS with assured benefits.

Check your preparation level for the AWS DevOps Engineer Professional exam with practice tests. Enroll for the AWS Certified DevOps Engineer Practice Tests now!

Getting Started with EKS

So, as we arrive towards the final phase of this discussion, it’s time to reflect on AWS EKS getting started. Let us reflect on an example of creating a simple application on the Kubernetes cluster by using EKS. The important steps involved in the process would include the following.

  • Creation of an AWS IAM service role and an AWS VPC
  • Creation of Amazon EKS cluster
  • Configuration of kubectl for Amazon EKS cluster
  • Launch and configuration of Amazon EKS worker nodes
  • Launching a simple application
  • Cleaning up the application and its assigned resources

Let us reflect on the first two steps in detail to understand the practical functionalities of AWS EKS.

Creating IAM Service Role and Amazon VPC

  • Start by navigating the AWS IAM Console to find the “Roles” section where you have to click on the “Create role” button.
  • Select “EKS” as the type of service and “AWS Service” as the type of entity.
  • Input a name for service role and click on “Create role” for creating the role.
  • You can create the VPC by clicking on “Create Stack” in the AWS CloudFormation console.
  • Select the option of “Specify an Amazon S3 template URL” and enter the concerned URL on the “Select Template” page.
  • Review and confirm the details after specifying them explicitly and then click on “Create” for proceeding ahead.

Creating an EKS Cluster

Now that you have the VPC and IAM service role, we can proceed towards creating an AWS EKS cluster. The creation of the EKS cluster would help in getting started with EKS easily.

  • Click on “Create cluster” button on the Amazon EKS console.
  • Input the details of the EKS cluster such as cluster name, security groups, role ARN, subnets and VPC
  • Just click on “Create”, and you can get your EKS cluster.
  • After configuration of the Kubernetes cluster, you can carry out other steps for deploying a Kubernetes application using EKS.

Preparing for an AWS DevOps Engineer Interview? Prepare with these top AWS DevOps Engineer Interview Questions and be ready to ace the interview!

Deploying a NodeJS application to the EKS

In this tutorial, we will walk you through the steps to deploy containerized NodeJs applications to Kubernetes. We will be seeing each step involved to achieve this including the creation of the Kubernetes cluster.

Prerequisites

To follow along with this tutorial, you will need the following setups.

  • An AWS account with necessary permissions (You can leverage Whizlabs HandsOn Labs environment for this)
  • AWS CLI installed on your local machine
  • The eksctl command line tool installed on your local machine
  • Docker installed on your local machine

Kubernetes on AWS

Kubernetes is an open-source container orchestration platform and it can be used within your on premise infrastructure. Several cloud providers also provide managed Kubernetes services as Platform as a Service (PaaS) such as Elastic Kubernetes Service (EKS) by Amazon, and Google Kubernetes Engine (GKE) by Google, Azure Kubernetes Service (AKS) by Azure. 

The Amazon Elastic Kubernetes Service (EKS) lets us deploy, run and scale our containerized applications within a Kubernetes cluster consisting of EC2 instances as worker nodes.

The Elastic Kubernetes Service(EKS) Architecture

The EKS has an uptime of 99.95%. The Amazon Elastic Kubernetes Service (EKS) consists of three main components.

  • Virtual Private Cloud (VPC)
  • Clusters
  • Nodes

The Virtual Private Cloud (VPC)

The VPC is an isolated networking environment within the AWS and is made up of other smaller components such as subnets, internet gateways, route tables, NAT gateways, etc. 

A VPC is mandatory for creating a Kubernetes cluster. The VPC should contain the subnets within at least two availability zones. It is recommended to have a combination of public and private subnets.

The EKS Clusters

An EKS cluster contains a control plane and the worker node within the VPC. The control plane runs the Kubernetes software and is placed in the AWS managed account.  The worker nodes are the EC2 instances that connect to the control plane through API Server from the Kubernetes software, and are placed on the user’s AWS account. 

There are multiple methods available to create an EKS cluster. 

  • Through AWS Console
  • AWS Command Line Interface (CLI)
  • AWS CloudFormation 
  • Terraform
  • eksctl

If we use command line utilities like AWS CLI or eksctl, we can provide the properties of a cluster through the command line arguments or by using a configuration files. 

In this tutorial we will be using eksctl command line tool create cluster.

Creating a Docker Container

In this step, we will create a cluster with deployment to run a docker image of a simple NodeJs application. 

Clone the source code from GitHub

Let us clone the sample code from the GitHub repository to our local by running the git clone command. 

git clone https://github.com/dharma1408/whizlabs-eks-demo.git

Create a Docker File

Open the cloned directory “whizlabs-eks-demo” and “Create a file named “Dockerfile”. Add the following code to the file. 

FROM node: alpine

WORKDIR /home/whizlabs-k8s-demo

COPY ..

RUN npm install

EXPOSE 3000

CMD exec node app.js

When we run the “docker run” command, the following actions will be performed:

Within the project directory, create another file named “.dockerignore”. This file will specify the files that should not be copied to the docker image. Add the following lines into the file

.git

.env

Let us now build our docker image by running the docker build command. 

docker build . -t whizlabs-k8s-demo

docker build cmd

We have successfully created the docker image for our NodeJs app. Let us now test this by running docker run command on the local. 

docker run -p 3000:3000 <IMAGE_Name>

docker run -p 3000:3000 whizlabs-k8s-demo

docker run

Let’s check the port 3000 on the browser.

nodeapp

Pushing the Docker image to Elastic Container Registry (ECR)

In this step, we will be pushing the created Docker file to the Elastic Container Registry(ECR). We will be doing this with command line tools.

Let’s run the ecr-public command to create a public repository within the Elastic Container Registry. I am creating it in the us-east-1 region. 

aws ecr-public create-repository –repository-name whizlabs-k8-ecr-repo –tags Key=environment,Value=development –region us-east-1

This command will return the values in JSON format describing the created repository. We will be using the repositoryUri from the JSON response as a tag to our Docker image.

ecr-repo-create

Now, run the docker tag command to tag the docker image. 

docker tag whizlabs-k8s-demo:latest <REPOSITORY_URI>:latest

docker tag whizlabs-k8s-demo:latest public.ecr.aws/a7c6l2b6/whizlabs-k8s-ecr-repo:latest

aws ecr-public get-login-password –region us-east-1 | docker login –username AWS –password-stdin public.ecr.aws

ecr-login

Now, run the docker push command. 

docker push <REPOSITORY_URI>

docker push public.ecr.aws/a7c6l2b6/whizlabs-k8s-ecr-repo:latest

docker push

Creating an EKS Cluster

In this step, let us create an EKS cluster which will use the docker image which we have pushed to the Elastic Container Registry(ECS). 

We will be using eksctl tool to create the cluster. The eksctl is a third party tool written in Go and it leverages the AWS CloudFormation to create and manage clusters. 

When we run the “eksctl create cluster” command without specifying the configuration file or passing the arguments through command line, then it will create cluster with the following default parameters. Reference: https://eksctl.io/

A cluster will be created with default parameters.

Let us now create a cluster and name it as whizlabs-k8s-cluster in the us-east-1 region.

eksctl create cluster –name whizlabs-k8s-cluster –region us-east-1

eksctl create cluster

We can also verify the cluster on the AWS console.

eks cluster aws demo

Now, we need to connect kubectl to the EKS cluster. For that, run the following command:

aws eks –region us-east-1 update-kubeconfig –name whizlabs-k8s-cluster

Creating Kubernetes Resources

In the previous step, we have created an empty Kubernetes cluster on the EKS.

Let’s create the deployment to deploy our node application to the cluster. 

eks-node-deploy

We have now successfully deployed our NodeJS application to the EKS cluster.

Are You Ready to Use EKS?

So, on a concluding note, we can clearly notice how easy it is to start with AWS EKS! First of all, EKS takes away a major portion of the administrative and operational burden on enterprises. You don’t have to manage or maintain master nodes for different containerized applications on EKS.

In addition, AWS-managed Kubernetes clusters have sufficient resilience to endure even the loss of an availability zone. You should keep in mind that you can also run RKS with the help of AWS Fargate. Fargate is the serverless compute engine for containers and takes away the need for provisioning or management of servers.

AWS EKS is the main topic to be covered for the AWS Certified DevOps Engineer Professional exam. If you’re preparing to become AWS DevOps Engineer, check out our AWS DevOps Engineer Professional training courses. Learn more about EKS right now and get started immediately for leveraging its promising benefits.

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top