An open API service indexing awesome lists of open source software.

https://github.com/notharshhaa/ci-cd_eks-github_actions

A fully automated CI/CD pipeline that builds, tests, and deploys a Node.js application on Amazon EKS using GitHub Actions, Terraform, and Kubernetes.
https://github.com/notharshhaa/ci-cd_eks-github_actions

aws aws-eks cicd devops eks eks-cluster github-actions jenkins nodejs

Last synced: 17 days ago
JSON representation

A fully automated CI/CD pipeline that builds, tests, and deploys a Node.js application on Amazon EKS using GitHub Actions, Terraform, and Kubernetes.

Awesome Lists containing this project

README

        

# **πŸš€ End-to-End CI/CD Pipeline for Node.js App Deployment on EKS using GitHub Actions**

![eksbanner](https://imgur.com/h87KAuY.png)

---

![CI/CD Pipeline](https://imgur.com/Ctznv2m.png)

## **πŸ“Œ Table of Contents**

- [**πŸš€ End-to-End CI/CD Pipeline for Node.js App Deployment on EKS using GitHub Actions**](#-end-to-end-cicd-pipeline-for-nodejs-app-deployment-on-eks-using-github-actions)
- [**πŸ“Œ Table of Contents**](#-table-of-contents)
- [**πŸ“‚ Repository Structure**](#-repository-structure)
- [**πŸ”§ Prerequisites**](#-prerequisites)
- [**βš™οΈ CI/CD Workflow**](#️-cicd-workflow)
- [**πŸ”¨ Build Job**](#-build-job)
- [**πŸš€ Deployment Job**](#-deployment-job)
- [**πŸ—οΈ Infrastructure Details**](#️-infrastructure-details)
- [**πŸ“¦ Application Deployment Strategy**](#-application-deployment-strategy)
- [**πŸ”„ GitOps Principles**](#-gitops-principles)
- [**πŸ”’ Security Best Practices**](#-security-best-practices)
- [**πŸ“’ Notifications \& Alerts**](#-notifications--alerts)
- [**πŸ“Š Monitoring \& Logging**](#-monitoring--logging)
- [**πŸ“œ Contributing**](#-contributing)
- [**⭐ Support \& Author**](#-support--author)
- [**⭐ Hit the Star!**](#-hit-the-star)
- [πŸ› οΈ **Author \& Community**](#️-author--community)
- [πŸ“§ **Let's Connect!**](#-lets-connect)
- [πŸ“’ **Stay Updated!**](#-stay-updated)

---

## **πŸ“‚ Repository Structure**

The repository is structured for **modularity and maintainability**.:

```tree
πŸ“‚ root
β”œβ”€β”€ πŸ“‚ app # Application source code
β”‚ β”œβ”€β”€ app.py # Python application logic (if applicable)
β”‚ β”œβ”€β”€ calculator.js # Business logic for calculations
β”‚ β”œβ”€β”€ calculator.test.js # Unit tests for calculator functions
β”‚ β”œβ”€β”€ Dockerfile # Dockerfile for building the Node.js app
β”‚ β”œβ”€β”€ Dockerfile-python # Dockerfile for a Python-based version (if needed)
β”‚ β”œβ”€β”€ 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 # Deployment definition for the application
β”‚ β”‚ β”œβ”€β”€ ingress.yaml # Ingress configuration for routing traffic
β”‚ β”‚ β”œβ”€β”€ kustomization.yaml # Kustomize configuration file
β”‚ β”‚ └── svc.yaml # Kubernetes Service definition
β”‚ β”‚
β”‚ β”œβ”€β”€ πŸ“‚ overlays # Environment-specific configurations
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ dev # Dev environment-specific Kustomize configs
β”‚ β”‚ β”‚ β”œβ”€β”€ deploy-dev.yaml # Dev-specific deployment file
β”‚ β”‚ β”‚ β”œβ”€β”€ ingress-dev.yaml # Dev-specific ingress settings
β”‚ β”‚ β”‚ β”œβ”€β”€ kustomization.yaml # Kustomize configuration for Dev
β”‚ β”‚ β”‚ └── svc-dev.yaml # Dev-specific service settings
β”‚ β”‚ β”‚
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ prod # Production environment-specific Kustomize configs
β”‚ β”‚ β”‚ β”œβ”€β”€ deploy-prod.yaml # Production-specific deployment file
β”‚ β”‚ β”‚ β”œβ”€β”€ ingress-prod.yaml # Production-specific ingress settings
β”‚ β”‚ β”‚ β”œβ”€β”€ kustomization.yaml # Kustomize configuration for Prod
β”‚ β”‚ β”‚ └── svc-prod.yaml # Production-specific service settings
β”‚ β”‚ β”‚
β”‚ β”‚ β”œβ”€β”€ πŸ“‚ staging # Staging environment-specific Kustomize configs
β”‚ β”‚ β”‚ β”œβ”€β”€ deploy-staging.yaml # Staging-specific deployment file
β”‚ β”‚ β”‚ β”œβ”€β”€ ingress-staging.yaml # Staging-specific ingress settings
β”‚ β”‚ β”‚ β”œβ”€β”€ kustomization.yaml # Kustomize configuration for Staging
β”‚ β”‚ β”‚ └── svc-staging.yaml # Staging-specific service settings
β”‚
β”œβ”€β”€ README.md # Project documentation and setup guide
β”‚
β”œβ”€β”€ πŸ“‚ terraform # Terraform configuration for infrastructure provisioning
β”‚ β”œβ”€β”€ ingress-nginx.tf # Terraform script for setting up NGINX Ingress
β”‚ β”œβ”€β”€ main.tf # Main Terraform file defining AWS infrastructure
β”‚ β”œβ”€β”€ outputs.tf # Defines Terraform outputs (e.g., cluster endpoints)
β”‚ β”œβ”€β”€ terraform.tf # Backend configuration for Terraform state management
β”‚ └── variables.tf # Input variables for Terraform modules
β”‚
└── VERSION # Tracks application versioning (Semantic Versioning)
```

---

## **πŸ”§ Prerequisites**

Before you proceed, ensure you have the following installed:

- πŸ›  **Node.js (>=14.x)**
- 🐳 **Docker (latest version)**
- πŸ—οΈ **Terraform (>=1.0)**
- ☸ **kubectl (latest version)**
- 🎭 **Kustomize**
- ☁ **AWS CLI & eksctl**
- βš™οΈ **GitHub Actions configured**
- πŸ”‘ **AWS IAM permissions to manage EKS**

---

## **βš™οΈ CI/CD Workflow**

The **CI/CD pipeline** automates the entire deployment process using **GitHub Actions**.

### **πŸ”¨ Build Job**

1️⃣ **Set Up the Environment**

- Install **Node.js dependencies** using `npm install`.
- Lint the code to ensure quality standards.

2️⃣ **Run Tests**

- Execute **unit tests** with `npm test`.
- Generate test reports for visibility.

3️⃣ **Version Management**

- Uses **Semantic Versioning** (`major.minor.patch`).
- Auto-increments the version based on commit messages.

4️⃣ **Build & Push Docker Image**

- **Builds a Docker image** of the application.
- Pushes it to **Amazon Elastic Container Registry (ECR)**.

---

### **πŸš€ Deployment Job**

1️⃣ **Terraform Setup**

- Initializes Terraform with `terraform init`.
- Ensures correct **state management**.

2️⃣ **Infrastructure Provisioning**

- Executes `terraform plan` and `terraform apply`.
- Deploys EKS clusters, networking, and storage.

3️⃣ **Kubernetes Configuration**

- Configures `kubectl` to interact with the cluster.
- Applies `Kustomize` overlays 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**.

---

## **πŸ—οΈ Infrastructure Details**

| 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.com`
- `staging.example.com`
- `prod.example.com`

---

## **πŸ“¦ Application Deployment Strategy**

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.

---

## **πŸ”„ GitOps Principles**

βœ” **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**.

---

## **πŸ”’ Security Best Practices**

πŸ” **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.

---

## **πŸ“’ Notifications & Alerts**

πŸ”” **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.

---

## **πŸ“Š Monitoring & Logging**

βœ… **Application Logs** – Aggregated using **Fluent Bit**.
βœ… **Infrastructure Logs** – Stored in **AWS CloudWatch Logs**.
βœ… **Metrics Monitoring** – Tracked using **Prometheus & Grafana**.

---

## **πŸ“œ Contributing**

Want to contribute? Here’s how:

1. **Fork the repository** & create a new branch.
2. Make your changes and **commit with a descriptive message**.
3. Open a **Pull Request (PR)** for review.

---

## **⭐ Support & Author**

## **⭐ Hit the Star!**

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! πŸš€

---

## πŸ› οΈ **Author & Community**

This project is crafted with passion by **[Harshhaa](https://github.com/NotHarshhaa)** πŸ’‘.

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!

---

## πŸ“§ **Let's Connect!**

Stay connected and explore more DevOps content with me:

[![LinkedIn](https://img.shields.io/badge/LinkedIn-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white)](https://linkedin.com/in/harshhaa-vardhan-reddy) [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/NotHarshhaa) [![Telegram](https://img.shields.io/badge/Telegram-26A5E4?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/prodevopsguy) [![Dev.to](https://img.shields.io/badge/Dev.to-0A0A0A?style=for-the-badge&logo=dev.to&logoColor=white)](https://dev.to/notharshhaa) [![Hashnode](https://img.shields.io/badge/Hashnode-2962FF?style=for-the-badge&logo=hashnode&logoColor=white)](https://hashnode.com/@prodevopsguy)

---

## πŸ“’ **Stay Updated!**

Want to stay up to date with the latest DevOps trends, best practices, and project updates? Follow me on my blogs and social channels!

![Follow Me](https://imgur.com/2j7GSPs.png)