Skip to main content

Command Palette

Search for a command to run...

How to Use AWS Elastic Kubernetes Service (EKS) for Containerized Applications

Published
β€’3 min read
How to Use AWS Elastic Kubernetes Service (EKS) for Containerized Applications
S

πŸš€ Software Geek | DevOps Engineer πŸ› οΈ Hi, I'm Sahil Patil, a passionate DevOps wizard dedicated to transforming code into cash by building scalable, high-performing, and reliable systems. With a knack for solving complex problems, I thrive on turning chaos into cloud-based efficiency through the seamless integration of DevOps practices and cloud solutions.My toolkit includes Kubernetes 🐳, Docker πŸ‹, and Terraform βš™οΈ, which I use to design robust, secure, and efficient infrastructure. Linux 🐧 is my playground, where I excel in troubleshooting and optimizing environments. AWS ☁️ serves as my canvas for crafting innovative cloud architectures.πŸ† Achievements: πŸŽ“ Awarded with Prime Minister Scholarship with All India Rank 2032.πŸ’Ό Selected for an internship at LRDE DRDO, Bengaluru.πŸ… Received Gaurav Puraskar from Defence Welfare, India.πŸ“œ Received KSB Scholarships from Kendriya Sainik Board, New Delhi.🌱 What Drives Me: I'm committed to continuous learning and staying ahead in the ever-evolving tech landscape. I actively participate in DevOps and cloud community meetups 🀝 to network with industry experts and exchange insights, helping me refine my skills and broaden my perspective.Let’s connect and collaborate to build something remarkable! πŸš€

How to Use AWS Elastic Kubernetes Service (EKS) for Containerized Applications πŸš€

AWS Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy to run containerized applications on AWS. It eliminates the complexity of managing Kubernetes clusters while ensuring high availability, scalability, and security. In this guide, we’ll cover how to deploy a containerized application on EKS step by step.


What is AWS EKS? πŸ€”

AWS EKS is a managed Kubernetes service that allows you to run, scale, and operate Kubernetes applications without needing to maintain control planes or worker nodes manually. It integrates seamlessly with AWS services like IAM, VPC, and CloudWatch for security, networking, and monitoring.

Why Use AWS EKS?

βœ… Fully managed - No need to set up or manage the Kubernetes control plane.
βœ… Highly available - EKS runs across multiple AWS Availability Zones (AZs).
βœ… Scalability - Easily scale your cluster and applications.
βœ… Security - Integrates with AWS IAM, VPC, and KMS for security.
βœ… Built-in Monitoring - Works with AWS CloudWatch and Prometheus for monitoring.


Step 1: Prerequisites πŸ› οΈ

Before deploying applications on EKS, ensure you have:

πŸ”Ή An AWS account with required permissions.
πŸ”Ή AWS CLI installed and configured.
πŸ”Ή kubectl installed (Kubernetes command-line tool).
πŸ”Ή eksctl installed (EKS cluster management tool).
πŸ”Ή Docker installed for containerizing applications.

πŸ‘‰ To install these tools, follow the official AWS documentation:
AWS CLI
kubectl
eksctl


Step 2: Create an EKS Cluster πŸ—οΈ

We will use eksctl to create an EKS cluster. Run the following command:

eksctl create cluster \
  --name my-cluster \
  --region us-east-1 \
  --nodegroup-name my-nodegroup \
  --node-type t3.medium \
  --nodes 2

πŸ“Œ Explanation:

  • --name my-cluster: Names the cluster.

  • --region us-east-1: Specifies the AWS region.

  • --nodegroup-name my-nodegroup: Names the worker node group.

  • --node-type t3.medium: Selects instance type for worker nodes.

  • --nodes 2: Creates 2 worker nodes.

This process takes 10-15 minutes to complete. You can verify your cluster using:

kubectl get nodes

Step 3: Deploy a Containerized Application 🐳

Let's deploy a simple Nginx web server on EKS.

1️⃣ Create a Deployment YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

2️⃣ Apply the deployment:

kubectl apply -f nginx-deployment.yaml

3️⃣ Check if the pods are running:

kubectl get pods

You should see 2 running pods.


Step 4: Expose the Application 🌐

To make the Nginx service accessible, we create a LoadBalancer service:

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer

Apply the service:

kubectl apply -f nginx-service.yaml

Check the service status:

kubectl get svc nginx-service

Once the EXTERNAL-IP is available, open it in your browser to see the running Nginx web server! πŸŽ‰


Step 5: Scale the Application πŸ“ˆ

Need more replicas? Scale your deployment with:

kubectl scale deployment nginx-deployment --replicas=5

Verify the new pods:

kubectl get pods

Step 6: Monitor the Cluster πŸ“Š

Using kubectl:

Check pod logs:

kubectl logs <pod-name>

Check pod status:

kubectl describe pod <pod-name>

Using AWS CloudWatch:

EKS integrates with CloudWatch for centralized logging. Enable logging using:

aws eks update-cluster-config \
  --name my-cluster \
  --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'

Step 7: Cleanup Resources πŸ—‘οΈ

When done, delete the cluster to avoid extra costs:

eksctl delete cluster --name my-cluster

Final Thoughts πŸ’‘

AWS EKS simplifies Kubernetes management, making it easy to deploy, scale, and monitor applications. By following this guide, you have:

βœ… Created an EKS cluster.
βœ… Deployed a containerized Nginx application.
βœ… Exposed it using a LoadBalancer.
βœ… Scaled the application.
βœ… Monitored the cluster.

More from this blog

S

Sahil's Blogs

132 posts

πŸ‘‹ Welcome to my Hashnode blog! I'm a DevOps Engineer, and this blog simplifies Cloud DevOps concepts. Get easy-to-understand articles to help you master DevOps and Cloud Technologies! πŸš€