GithubHelp home page GithubHelp logo

harshgupta-coder / k8s-eks-fargate-ingress-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

A step-by-step guide and configurations for setting up a Kubernetes cluster on AWS Elastic Kubernetes Service (EKS) with Fargate, deploying an application using an Application Load Balancer (ALB) through AWS Load Balancer Controller, and showcasing the power of Kubernetes Ingress for efficient traffic routing.

k8s-eks-fargate-ingress-demo's Introduction

k8s-eks-fargate-ingress-demo

A step-by-step guide and configurations for setting up a Kubernetes cluster on AWS Elastic Kubernetes Service (EKS) with Fargate, deploying an application using an Application Load Balancer (ALB) through AWS Load Balancer Controller, and showcasing the power of Kubernetes Ingress for efficient traffic routing.

Kubernetes Cluster Setup and Demo with AWS EKS

This repository contains instructions and configurations for setting up a Kubernetes cluster on AWS Elastic Kubernetes Service (EKS) using Fargate. The demonstration includes deploying an application with an Application Load Balancer (ALB) using AWS Load Balancer Controller.

Prerequisites

Ensure you have the following tools installed on your local machine:

  • Helm
  • eksctl
  • AWS CLI
  • kubectl

AWS Configuration

  1. Run aws configure on your local terminal and provide AWS Access ID and Secret Access Key.

    This step configures your AWS CLI with the necessary credentials to interact with your AWS account.

EKS Cluster Setup

  1. Create an EKS cluster using the following command:

    eksctl create cluster --name demo-cluster --region us-east-1 --fargate

    This command uses eksctl to create an EKS cluster named 'demo-cluster' in the 'us-east-1' region with Fargate as the compute engine.

    image

  2. Connect kubectl to the EKS cluster:

    aws eks update-kubeconfig --name demo-cluster --region us-east-1

    This command configures kubectl to communicate with the newly created EKS cluster.

  3. Create a Fargate profile:

    eksctl create fargateprofile \
        --cluster demo-cluster \
        --region us-east-1 \
        --name alb-sample-app \
        --namespace game-2048

    Fargate profiles allow you to run Kubernetes pods without managing the underlying EC2 instances.

    image

Deploying Application with ALB

  1. Apply the configuration for the application, service, and ingress:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/examples/2048/2048_full.yaml

    This step deploys the 2048 game application using the provided YAML configuration. The YAML file defines the deployment, service, and ingress for the application.

  2. Check the status of pods, services, and ingress:

    kubectl get pods -n game-2048
    kubectl get services -n game-2048
    kubectl get ingress -n game-2048

    Use these commands to verify that the application pods, services, and ingress resources are running as expected.

    image

IAM OIDC Connector and ALB Ingress Controller

  1. Associate IAM OIDC provider:

    eksctl utils associate-iam-oidc-provider --cluster demo-cluster --approve

    This step associates the IAM OIDC provider with the EKS cluster, allowing it to authenticate Kubernetes service accounts.

  2. Download and create IAM policy:

    curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json
    
    aws iam create-policy \
        --policy-name AWSLoadBalancerControllerIAMPolicy \
        --policy-document file://iam_policy.json

    Attach the IAM policy to the service account:

    eksctl create iamserviceaccount \
        --cluster=demo-cluster \
        --namespace=kube-system \
        --name=aws-load-balancer-controller \
        --role-name AmazonEKSLoadBalancerControllerRole \
        --attach-policy-arn=arn:aws:iam::<your-aws-account-id>:policy/AWSLoadBalancerControllerIAMPolicy \
        --approve \
        --override-existing-serviceaccounts

    These steps set up the necessary IAM policies to allow the ALB Ingress Controller to interact with AWS services.

Installing ALB Ingress Controller with Helm

  1. Install the ALB Ingress Controller using Helm:

    helm repo add eks https://aws.github.io/eks-charts
    
    helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system \
      --set clusterName=demo-cluster \
      --set serviceAccount.create=false \
      --set serviceAccount.name=aws-load-balancer-controller \
      --set region=<region> \
      --set vpcId=<your-vpc-id>

    Helm is used to deploy the ALB Ingress Controller to the Kubernetes cluster. This command installs the controller with specific configurations.

  2. Verify the ALB Ingress Controller deployment:

    kubectl get deployment -n kube-system aws-load-balancer-controller

Ensure that the ALB Ingress Controller is running with the desired number of replicas.

image

  1. Access the application through the ALB in the AWS console:

    Navigate to the AWS console, go to the EC2 section, and find the Load Balancer. Retrieve the DNS name and access it in the browser to confirm the successful deployment of the application.

    image

Congratulations! Your Kubernetes cluster with Fargate and ALB is now set up, and the application is deployed.

image

k8s-eks-fargate-ingress-demo's People

Contributors

harshgupta-coder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.