Back to .md Directory

AWS EKS Deployment with GitHub Actions CI/CD

Documents a GitHub Actions CI/CD pipeline that builds, scans, and deploys a containerized app to AWS EKS with SonarCloud and Trivy.

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

What this file does

Documents a GitHub Actions CI/CD pipeline that builds, scans, and deploys a containerized app to AWS EKS with SonarCloud and Trivy.

When to use it

  • Setting up a CI/CD pipeline for a containerized app on AWS EKS
  • Integrating SonarCloud code quality checks into a deployment workflow
  • Adding Trivy security scanning to a Docker image build pipeline
  • Learning how to push images to Amazon ECR and deploy with kubectl

Assumes this stack

GitHub ActionsAWS EKSAmazon ECRSonarCloudTrivykubectl

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.

What's inside

8 sections, 1 bash command with flag explanations, 6 screenshots, and a conclusion

Change this for your project

  • Replace actions-eks-cluster with your own EKS cluster name
  • Replace us-east-1 with your target AWS region
  • Replace t3.medium with your desired EC2 instance type

Where it goes

Keep it in your repository where the agent or team that needs it will read it.

Worth borrowing

  • Combining SonarCloud and Trivy in the same pipeline for quality and security gates
  • Using eksctl with managed node groups for simplified cluster creation

Related Documents