Back to .md Directory

AWS EKS Deployment with GitHub Actions CI/CD

This repository demonstrates a CI/CD pipeline for deploying a containerized application to **Amazon Elastic Kubernetes Service (EKS)** using **GitHub Actions**. The pipeline incorporates **SonarCloud** for code quality checks, **Trivy** for security scans, and **Amazon ECR** for container image storage.

May 2, 2026
0 downloads
0 views
ai rag workflow
View source

AWS EKS Deployment with GitHub Actions CI/CD

This repository demonstrates a CI/CD pipeline for deploying a containerized application to Amazon Elastic Kubernetes Service (EKS) using GitHub Actions. The pipeline incorporates SonarCloud for code quality checks, Trivy for security scans, and Amazon ECR for container image storage.


Features

  • CI/CD Pipeline: Automates building, testing, and deploying the application.
  • Code Quality Analysis: Uses SonarCloud to ensure code meets quality standards.
  • Security Scanning: Implements Trivy to identify vulnerabilities in Docker images.
  • AWS Integration: Pushes container images to Amazon ECR and deploys to Amazon EKS.
  • Infrastructure as Code: Deploys Kubernetes resources via kubectl.

Workflow Overview

Below is a breakdown of the CI/CD pipeline with images illustrating each step.


1. Checkout Code

The first step pulls the latest code from the repository using the actions/checkout GitHub Action.

Checkout Code


2. SonarCloud Analysis

Scans the codebase for issues like bugs, vulnerabilities, and code smells.

SonarCloud Analysis


3. Trivy Scan

Scans the built Docker image for vulnerabilities to ensure secure deployments.

Set Up Node.js


4. Push Image to Amazon ECR

Pushes the Docker image to Amazon Elastic Container Registry (ECR).

Screenshot 2024-11-21 at 11 36 11

5. AWS cli configure

Builds a Docker image of the application and tags it using the commit SHA.

Build Docker Image



5. Create cluster for kubernetes deployment

eksctl create cluster \
  --name actions-eks-cluster \
  --region us-east-1 \
  --nodes 1 \
  --nodegroup-name actions-eks \
  --node-type t3.medium \
  --nodes-min 1 \
  --nodes-max 3 \
  --managed

Explanation of Flags

  1. --name actions-eks-cluster:

    • Specifies the name of the EKS cluster.
  2. --region us-east-1:

    • Sets the AWS region for your EKS cluster.
  3. --nodes 1:

    • Sets the initial number of nodes for the cluster.
  4. --nodegroup-name actions-eks:

    • Names the node group for easier management.
  5. --node-type t3.medium:

    • Specifies the EC2 instance type for the nodes in the cluster. t3.medium is cost-effective and sufficient for light workloads.
  6. --nodes-min 1:

    • Sets the minimum number of nodes in the node group.
  7. --nodes-max 3:

    • Sets the maximum number of nodes in the node group for scaling.
  8. --managed:

    • Enables AWS-managed node groups, which simplifies lifecycle management of nodes.

Verify Cluster Creation: After running the command, check the status of your cluster:

eksctl get cluster --region us-east-1

or

eksctl get cluster --name actions-eks-cluster 

Screenshot 2024-11-21 at 12 17 50


8.

it listens on port 3000 so we open port 300 from our load balancer and access on the external ip

Screenshot 2024-11-21 at 12 37 39


  • Deployed Application

Screenshot 2024-11-21 at 12 39 52

Conclusion

This project demonstrates a complete CI/CD pipeline for deploying containerized applications to AWS EKS. It incorporates robust practices like code quality checks and security scans to ensure reliable and secure deployments.

Related Documents