DEV Community

Koti Vellanki
Koti Vellanki

Posted on

AWS EKS Made Easy: Deploy Your First Kubernetes Cluster Today

Welcome to Day 3 of our 15-day AWS Containers learning series! After learning the foundational concepts of containers, we are now diving into one of the most exciting aspects—scaling containers. Today, we’ll be exploring how AWS services like ECS (Elastic Container Service) and EKS (Elastic Kubernetes Service) empower us to scale containerized applications seamlessly.

Let’s continue with Ovi and her dad’s story as they explore the world of container scaling!

The Story: Ovi Scales Her Toy Collection

It's the same 9 PM, and Ovi is sitting next to her dad, who’s wrapping up his work. After hearing about containers in the past few days, Ovi is eager to know how containers scale. She excitedly asks, “Dad, what if I want to take more toys to grandma's house than just the usual ones? Can my toy box hold more?”

Her dad chuckles and begins, "Well, Ovi, what if you could have many toy boxes that you could add or remove depending on how many toys you want to carry? That way, you’d never run out of space, and you could always bring just the right number of toys with you. In the container world, that’s called scaling—it’s like having the ability to add or remove toy boxes as needed!"

What is Scaling?

Scaling means adjusting the number of containers running at any given time based on demand. Just like Ovi can add or remove toy boxes based on how many toys she needs to carry, scaling containers allows your applications to grow or shrink to meet the load.

There are two types of scaling:

  • Vertical Scaling: Adding more resources (CPU, RAM) to a single container.
  • Horizontal Scaling: Adding or removing containers to handle the load.

Her dad continues, “Let’s explore how AWS makes scaling containers easy, using ECS and EKS.”

ECS (Elastic Container Service) - Simplifying Container Orchestration

AWS ECS is a fully managed container orchestration service that allows you to easily run and scale containerized applications.

Here’s how ECS works:

  • Task Definitions: These are blueprints for your containers, similar to the design of your toy box, which defines what goes inside and how it works.
  • Clusters: These are groups of EC2 instances or Fargate instances where your containers run. Think of them like the shelves where your toy boxes are kept.
  • Services: Services ensure that the desired number of containers are always running. It’s like having a manager who makes sure that there are always enough toy boxes available.

How ECS Handles Scaling:

  1. Auto-Scaling: ECS has built-in auto-scaling features that allow you to scale your container services up or down based on metrics like CPU usage, memory usage, or network traffic.

    • Example: Imagine a busy day at grandma’s house, and you need more toy boxes to carry extra toys. ECS will automatically scale up the number of containers based on the load!
  2. Launch Types: ECS offers two launch types: EC2 (where you manage the EC2 instances) and Fargate (a serverless option where AWS manages the infrastructure).

    • Example: If Ovi decides to have a party with her friends and needs more toys, she can scale up using Fargate without worrying about the infrastructure.

What Is Kubernetes?

Kubernetes (K8s) is an open-source platform for automating the deployment, scaling, and management of containerized applications. It ensures that your applications run reliably, even when the workload fluctuates.

Why Kubernetes?

  • Scalability: Automatically adjust workloads based on demand.
  • Portability: Works across multiple cloud environments or on-premises.
  • Self-Healing: Restarts failed containers or replaces unhealthy ones.
  • Load Balancing: Distributes traffic evenly across containers.

Introducing Amazon EKS

Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service by AWS. It simplifies the setup, operation, and maintenance of Kubernetes clusters, so you can focus on building applications instead of managing infrastructure.

Key Features of EKS:

  • Fully managed control plane.
  • Integrated with AWS services (e.g., IAM, VPC, CloudWatch).
  • Compatible with upstream Kubernetes (no vendor lock-in).
  • Automatic patching and updates for the Kubernetes control plane.

Components of an EKS Cluster

Ovi’s dad explains, “Let’s break down the main parts of an EKS cluster, just like understanding the pieces of a puzzle.”

  1. Control Plane:

    • Manages the Kubernetes API server and etcd database.
    • In EKS, AWS handles this part for you.
  2. Worker Nodes:

    • These are EC2 instances or Fargate tasks that run your containerized applications.
  3. Pods:

    • Smallest deployable units in Kubernetes, containing one or more containers.
  4. Services:

    • Enable communication between pods or expose them to the outside world.
  5. Namespaces:

    • Divide cluster resources for different teams or projects.

EKS (Elastic Kubernetes Service) - Scaling with Kubernetes

While ECS is great for most use cases, some organizations prefer Kubernetes for container orchestration due to its flexibility and vast ecosystem. EKS is AWS’s fully managed Kubernetes service.

Key EKS Features for Scaling:

  1. Pods: Kubernetes runs containers inside pods. A pod can run one or multiple containers.

    • Example: A pod is like a group of toy boxes that are always kept together, no matter how many toys (containers) they hold.
  2. Horizontal Pod Autoscaling: EKS allows you to automatically scale the number of pods based on resource utilization or custom metrics.

    • Example: If grandma’s house gets overcrowded, EKS can add more toy boxes to handle the extra toys without you doing anything!
  3. Cluster Autoscaler: This feature automatically adjusts the size of your Kubernetes cluster by adding or removing nodes (EC2 instances) based on resource demand.

    • Example: If too many toys (pods) need storage, the cluster autoscaler adds more shelves (nodes) to keep things organized.

ECS vs EKS: Which One to Choose?

Here’s a comparison between ECS and EKS to help you decide which service best fits your use case:

Feature ECS EKS
Management Fully managed by AWS Fully managed, but Kubernetes knowledge required
Scaling Easy auto-scaling and task management More granular scaling with Kubernetes tools
Use Case Simple, quick deployment of containers Complex applications requiring Kubernetes features
Launch Type EC2 or Fargate EC2 (managed Kubernetes)
Ease of Use Easier to get started Requires more expertise in Kubernetes

Hands-On Lab: Setting Up Your First EKS Cluster

Let’s get practical! Follow these steps to create an EKS cluster:

Prerequisites

  • An AWS account with administrative privileges.
  • AWS CLI, kubectl, and eksctl installed on your machine.

Step 1: Configure AWS CLI

aws configure
Enter fullscreen mode Exit fullscreen mode

Provide your AWS credentials and default region.

Step 2: Install eksctl

Use eksctl to create and manage EKS clusters.

curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/v0.150.0/eksctl_$(uname -s)_$(uname -m).tar.gz" | tar xz -C /usr/local/bin
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

eksctl version
Enter fullscreen mode Exit fullscreen mode

Step 3: Create an EKS Cluster

Run the following command to create a simple cluster with two worker nodes:

eksctl create cluster \
  --name my-eks-cluster \
  --region us-west-2 \
  --nodegroup-name linux-nodes \
  --node-type t3.medium \
  --nodes 2 \
  --nodes-min 1 \
  --nodes-max 3 \
  --managed
Enter fullscreen mode Exit fullscreen mode

This process takes about 10-15 minutes.

Step 4: Verify the Cluster

Once the cluster is ready, configure kubectl to connect to it:

aws eks update-kubeconfig --region us-west-2 --name my-eks-cluster
Enter fullscreen mode Exit fullscreen mode

Check the cluster nodes:

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

You should see the worker nodes listed.

Step 5: Deploy a Sample Application

Deploy an NGINX web server to test the cluster:

kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=LoadBalancer
Enter fullscreen mode Exit fullscreen mode

Get the external IP address:

kubectl get services
Enter fullscreen mode Exit fullscreen mode

Access the NGINX web server via the external IP.


Real-Life Analogy: Kubernetes as a Traffic Cop

“Ovi, imagine a traffic cop at a busy intersection,” her dad says. “The cop ensures cars move smoothly without crashing or getting stuck. Similarly, Kubernetes directs your containers, ensuring everything runs seamlessly.”


Troubleshooting Tips

  • Cluster Not Ready? Check the status using:
  eksctl get cluster --name my-eks-cluster
Enter fullscreen mode Exit fullscreen mode
  • kubectl Errors? Ensure your kubeconfig file is correctly set up.

Summary: Key Takeaways

By the end of today, you’ve learned:

  • The basics of Kubernetes and its role in managing containers.
  • The main components of an EKS cluster.
  • How to create and test your first EKS cluster using eksctl.

What’s Next?

Next, we’ll dive into Amazon Elastic Container Registry (ECR) and learn how to securely store and manage container images. Stay tuned for Day 4!

Let’s connect!

See you in the next episode!

Top comments (0)