EASIEST EKS Cluster Setup & Deployment of Two-Tier Application | Episode 6

3 min read 6 months ago
Published on Aug 13, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial provides a step-by-step guide to setting up an Amazon EKS (Elastic Kubernetes Service) cluster and deploying a two-tier application. This process is pivotal for developers and DevOps engineers looking to leverage Kubernetes for scalable application deployment. By following these steps, you'll gain practical experience with EKS and understand the deployment architecture for modern applications.

Step 1: Set Up AWS CLI and Configure Credentials

To begin, ensure you have the AWS Command Line Interface (CLI) installed and configured on your machine.

  • Install the AWS CLI if you haven't already.
  • Configure your AWS credentials by running the following command:
    aws configure
    
  • Enter your AWS Access Key, Secret Key, region, and output format when prompted.

Step 2: Create an EKS Cluster

Next, you will create an EKS cluster via the AWS Management Console or CLI.

  • Using AWS CLI:

    1. Create a new EKS cluster:
      aws eks create-cluster --name my-cluster --role-arn <EKS_ROLE_ARN> --resources-vpc-config subnetIds=<SUBNET_ID_1>,<SUBNET_ID_2>,securityGroupIds=<SECURITY_GROUP_ID>
      
    2. Monitor the cluster creation status:
      aws eks describe-cluster --name my-cluster --query "cluster.status"
      
  • Using AWS Console:

    1. Navigate to the EKS service.
    2. Click on "Create cluster" and follow the prompts to configure your cluster settings.

Step 3: Configure kubectl

Once the cluster is created, configure kubectl to interact with your EKS cluster.

  • Update your kubeconfig file:
    aws eks update-kubeconfig --name my-cluster
    
  • Verify that kubectl is configured correctly:
    kubectl get svc
    

Step 4: Deploy the Two-Tier Application

Now, let's deploy a two-tier application using Kubernetes manifests.

  • Clone the application repository:
    git clone https://github.com/LondheShubham153/two-tier-flask-app.git
    cd two-tier-flask-app
    
  • Apply the Kubernetes manifests:
    kubectl apply -f deployment.yaml
    kubectl apply -f service.yaml
    

Step 5: Expose the Application

Expose your application to the internet by creating a LoadBalancer service.

  • Update your service configuration (service.yaml) to include a LoadBalancer type:

    apiVersion: v1
    kind: Service
    metadata:
      name: my-app
    spec:
      type: LoadBalancer
      ports:
        - port: 80
      selector:
        app: my-app
    
  • Apply the updated service configuration:

    kubectl apply -f service.yaml
    

Step 6: Check Application Status

After deployment, check if the application is running correctly.

  • Get the external IP of the LoadBalancer:
    kubectl get svc my-app
    
  • Access your application using the external IP in your web browser.

Conclusion

In this tutorial, you've successfully set up an EKS cluster and deployed a two-tier application. This guide covered the essential steps from AWS CLI configuration to application deployment. As a next step, consider exploring scaling options, monitoring your application, and implementing CI/CD pipelines for automated deployments. For further learning, check out additional resources and playlists provided in the video description.