- π End-to-End CI/CD Pipeline for Node.js App Deployment on EKS using GitHub Actions
- π Table of Contents
- π Repository Structure
- π§ Prerequisites
- βοΈ CI/CD Workflow
- ποΈ Infrastructure Details
- π¦ Application Deployment Strategy
- π GitOps Principles
- π Security Best Practices
- π’ Notifications & Alerts
- π Monitoring & Logging
- π Contributing
- β Support & Author
- β Hit the Star!
- π οΈ Author & Community
- π§ Let's Connect!
- π’ Stay Updated!
The repository is structured for modularity and maintainability:
π root
βββ π .github/workflows/ # GitHub Actions CI/CD workflows
β βββ ci.yml # Pure CI pipeline (testing, linting, security)
β βββ cd-production.yml # Production deployment pipeline
β βββ deployment.yml # Multi-environment deployment with versioning
β
βββ π app # Application source code
β βββ calculator.js # Business logic for calculations
β βββ calculator.test.js # Unit tests for calculator functions
β βββ Dockerfile # Optimized Dockerfile for Node.js app
β βββ index.js # Main entry point of the Node.js application
β βββ package.json # Project dependencies and scripts
β
βββ π kustomize # Kubernetes manifests managed with Kustomize
β βββ π base # Base configurations common for all environments
β β βββ deploy.yaml # Enhanced deployment with health checks & security
β β βββ ingress.yaml # Ingress configuration for routing traffic
β β βββ kustomization.yaml # Kustomize configuration with image management
β β βββ svc.yaml # Kubernetes Service definition
β β
β βββ π overlays # Environment-specific configurations
β β βββ π dev # Dev environment-specific Kustomize configs
β β βββ π prod # Production environment with enhanced security
β β βββ π staging # Staging environment-specific configs
β
βββ π terraform # Terraform configuration for infrastructure provisioning
β βββ ingress-nginx.tf # Terraform script for setting up NGINX Ingress
β βββ main.tf # Main Terraform file with EKS 1.29 & enhanced security
β βββ outputs.tf # Defines Terraform outputs
β βββ terraform.tf # Backend configuration with latest providers
β βββ variables.tf # Input variables for Terraform modules
β
βββ .eslintrc.js # Enhanced ESLint with security plugins
βββ .gitignore # Optimized gitignore with comprehensive coverage
βββ docker-compose.yml # Enhanced local development with Redis & SSL
βββ nginx.conf # Production-ready Nginx with security headers
βββ README.md # Project documentation and setup guide
βββ VERSION # Tracks application versioning (Semantic Versioning)
This project has been comprehensively enhanced with modern best practices and security improvements:
- β Organized Workflow Structure - Clear separation: CI, Production CD, Multi-Environment Deployment
- β Pure CI Pipeline - Testing, linting, security scanning (ci.yml)
- β Production CD - ECR integration, production deployment (cd-production.yml)
- β Multi-Environment Deployment - Version management, Terraform, DNS (deployment.yml)
- β Latest Action Versions - checkout@v4, setup-node@v4, codecov@v4
- β Enhanced CI Pipeline - Multi-node testing (18.x, 20.x) with fail-fast disabled
- β Security Scanning - Trivy vulnerability scanning with SARIF upload
- β Master Branch Support - Updated workflows to use master branch instead of main
- β EKS 1.29 - Latest stable version with enhanced add-ons
- β Modern Providers - AWS ~>5.50, Kubernetes ~>2.24, Helm ~>2.12
- β Enhanced Security - Encrypted GP3 volumes, private endpoints, CNI policies
- β Better Tagging - Comprehensive resource tagging strategy
- β Version Constraints - Terraform >=1.5.0 with provider version locking
- β Image Management - Centralized image tagging and updates
- β Enhanced Production - 3 replicas, proper secret management, environment configs
- β Better Structure - Improved base configuration with replica management
- β Secret Handling - Environment-based secret generation
- β Redis Cache - Added Redis service for improved performance
- β SSL Support - HTTPS termination with modern cipher suites
- β Enhanced Nginx - Security headers, rate limiting, gzip compression
- β Health Checks - Comprehensive health monitoring for all services
- β Better Networking - Dedicated bridge network and volume management
- β Security ESLint - Security plugins, import rules, promise handling
- β Optimized Gitignore - Clean, organized, comprehensive coverage
- β Code Quality - ES2022 standards, security-focused linting
- β Modern Standards - Latest Node.js 20 with proper caching
Before you proceed, ensure you have the following installed:
- π Node.js (>=20.x)
- π³ Docker & Docker Compose
- ποΈ Terraform (>=1.5.0)
- βΈ kubectl (latest version)
- π Kustomize
- β AWS CLI & eksctl
- βοΈ GitHub Actions configured
- π AWS IAM permissions to manage EKS
- π Security scanning tools (Trivy, CodeQL)
# Clone the repository
git clone https://github.com/NotHarshhaa/CI-CD_EKS-GitHub_Actions.git
cd CI-CD_EKS-GitHub_Actions
# Start the application with Docker Compose
docker-compose up --build
# Access the application
# Web UI: http://localhost:80
# Health Check: http://localhost:80/health
# API: POST http://localhost:80/api/calculate# Navigate to app directory
cd app
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Run linting
npm run lintThe CI/CD pipeline is organized into three specialized workflows using GitHub Actions:
Triggers: Push/PR to master, develop, staging
1οΈβ£ Code Quality Checks
- Install Node.js dependencies using
npm ci - Run linting to ensure code quality standards
2οΈβ£ Testing & Coverage
- Execute unit tests across Node.js 18.x and 20.x
- Generate coverage reports with Codecov integration
3οΈβ£ Security Scanning
- Run Trivy vulnerability scanner on codebase
- Upload SARIF results to GitHub Security tab
Triggers: Push to master, tags, manual dispatch
1οΈβ£ Build & Push
- Build Docker image with production optimizations
- Push to Amazon ECR with SHA tagging
2οΈβ£ Deploy to EKS
- Update Kubernetes manifests using Kustomize
- Deploy to production EKS cluster
3οΈβ£ Verification
- Health checks and smoke tests
- Security scanning of deployed image
Triggers: Push to prod/dev/staging, PR to dev
1οΈβ£ Version Management
- Semantic versioning based on commit messages
- Auto-tag and version file updates
2οΈβ£ Infrastructure Provisioning
- Terraform EKS cluster management
- Multi-environment infrastructure setup
3οΈβ£ Application Deployment
- Docker builds for each environment
- Kustomize deployments with environment-specific configs
- DNS management via Cloudflare
4οΈβ£ Notifications
- Slack integration for deployment status
- Comprehensive deployment reporting
1οΈβ£ Terraform Setup
- Initializes Terraform with
terraform init. - Ensures correct state management.
2οΈβ£ Infrastructure Provisioning
- Executes
terraform planandterraform apply. - Deploys EKS clusters, networking, and storage.
3οΈβ£ Kubernetes Configuration
- Configures
kubectlto interact with the cluster. - Applies
Kustomizeoverlays for environment-specific settings.
4οΈβ£ Ingress Controller Setup
- Uses Helm to install NGINX Ingress.
5οΈβ£ Application Deployment
- Deploys the latest Docker image to Kubernetes.
- Exposes the service via Ingress and Load Balancer.
| Environment | Instance Type | Replica Count |
|---|---|---|
| Dev | t3.small |
1 |
| Staging | t3.medium |
3 |
| Prod | t3.large |
3 |
β DNS Automation via Cloudflare
- Environment-specific subdomains:
dev.example.comstaging.example.comprod.example.com
This project supports multiple deployment strategies:
β
Rolling Updates β Default strategy, ensuring zero downtime.
β
Blue-Green Deployment β Used in production environments.
β
Canary Deployments β Gradual rollout for safe updates.
β Git as the Source of Truth
β Declarative Infrastructure (Terraform & Kubernetes)
β Automated Deployments via GitHub Actions
Every infrastructure change must be made via a Git commit.
π Secrets Management
- Uses AWS Secrets Manager & GitHub Actions encrypted secrets.
π‘ Container Security
- Uses Trivy and Docker Bench Security for vulnerability scanning.
π§ IAM & Least Privilege
- Uses AWS IAM roles with restricted access.
π Slack & Email Notifications
- CI/CD Job Updates β Pipeline status alerts.
- DNS Updates β Cloudflare integration for alerts.
π‘ Monitoring & Logging
- AWS CloudWatch for logs & metrics.
- Prometheus & Grafana for observability.
β
Application Logs β Aggregated using Fluent Bit.
β
Infrastructure Logs β Stored in AWS CloudWatch Logs.
β
Metrics Monitoring β Tracked using Prometheus & Grafana.
Want to contribute? Hereβs how:
- Fork the repository & create a new branch.
- Make your changes and commit with a descriptive message.
- Open a Pull Request (PR) for review.
If you find this repository helpful and plan to use it for learning, please consider giving it a star β. Your support motivates me to keep improving and adding more valuable content! π
This project is crafted with passion by Harshhaa π‘.
Iβd love to hear your feedback! Feel free to open an issue, suggest improvements, or just drop by for a discussion. Letβs build a strong DevOps community together!
Stay connected and explore more DevOps content with me:
Want to stay up to date with the latest DevOps trends, best practices, and project updates? Follow me on my blogs and social channels!


