Logo

dev-resources.site

for different kinds of informations.

AWS EKS Made Easy: Deploy Your First Kubernetes Cluster Today

Published at
12/16/2024
Categories
aws
community
devops
kubernetes
Author
Koti Vellanki
Categories
4 categories in total
aws
open
community
open
devops
open
kubernetes
open
AWS EKS Made Easy: Deploy Your First Kubernetes Cluster Today

Day 3: Scaling Containers with Amazon EKS

"Learn how to deploy and scale your first Kubernetes cluster with Amazon EKS in just a few steps!"

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 explore how Amazon Elastic Kubernetes Service (EKS) empowers us to deploy and scale containerized applications seamlessly.

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

Table of Contents

  1. The Story: Ovi Scales Her Toy Collection
  2. What Is Scaling?
    • Types of Scaling
  3. What Is Kubernetes?
    • Why Kubernetes?
  4. Introducing Amazon EKS
    • Key Features of EKS
    • Components of an EKS Cluster
  5. EKS Scaling Features
    • Horizontal Pod Autoscaling
    • Cluster Autoscaler
  6. ECS vs. EKS: Which One to Choose?
  7. Hands-On Lab: Setting Up Your First EKS Cluster
  8. Real-Life Analogy: Kubernetes as a Traffic Cop
  9. Troubleshooting Tips
  10. Summary: Key Takeaways
  11. What’s Next?

The Story: Ovi Scales Her Toy Collection

It’s 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.

Types of Scaling

  1. Vertical Scaling: Adding more resources (CPU, RAM) to a single container.
  2. 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.”

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?

  1. Scalability: Automatically adjusts workloads based on demand.
  2. Portability: Works across multiple cloud environments or on-premises.
  3. Self-Healing: Restarts failed containers or replaces unhealthy ones.
  4. 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

  1. Fully managed control plane.
  2. Integrated with AWS services (e.g., IAM, VPC, CloudWatch).
  3. Compatible with upstream Kubernetes (no vendor lock-in).
  4. 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 Scaling Features

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 (pods) to handle the extra toys without you doing anything!

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?

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

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

Step 1: Configure AWS CLI

aws configure

Provide your AWS credentials and default region.

Step 2: Install eksctl

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

Verify the installation:

eksctl version

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

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

Check the cluster nodes:

kubectl get nodes

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

Get the external IP address:

kubectl get services

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

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

Summary: Key Takeaways

By the end of today, you’ve learned:

  1. The basics of Kubernetes and its role in managing containers.
  2. The main components of an EKS cluster.
  3. 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!

Found this helpful? Share it with your network and help others learn about EKS!

See you in the next episode! 🚀

Featured ones: