dev-resources.site
for different kinds of informations.
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
- The Story: Ovi Scales Her Toy Collection
-
What Is Scaling?
- Types of Scaling
-
What Is Kubernetes?
- Why Kubernetes?
-
Introducing Amazon EKS
- Key Features of EKS
- Components of an EKS Cluster
-
EKS Scaling Features
- Horizontal Pod Autoscaling
- Cluster Autoscaler
- ECS vs. EKS: Which One to Choose?
- Hands-On Lab: Setting Up Your First EKS Cluster
- Real-Life Analogy: Kubernetes as a Traffic Cop
- Troubleshooting Tips
- Summary: Key Takeaways
- 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
- 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.”
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 adjusts 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.”
-
Control Plane:
- Manages the Kubernetes API server and etcd database.
- In EKS, AWS handles this part for you.
-
Worker Nodes:
- These are EC2 instances or Fargate tasks that run your containerized applications.
-
Pods:
- Smallest deployable units in Kubernetes, containing one or more containers.
-
Services:
- Enable communication between pods or expose them to the outside world.
-
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
- An AWS account with administrative privileges.
- AWS CLI,
kubectl
, andeksctl
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
- Cluster Not Ready? Check the status using:
eksctl get cluster --name my-eks-cluster
- 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!
Found this helpful? Share it with your network and help others learn about EKS!
- LinkedIn: Vellanki Koti
- X (formerly Twitter): @DevOpsCircuit
- Dev.to: Vellanki
See you in the next episode! 🚀
Featured ones: