Skip to content

KRC00112/NotesAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues CI CD


NotesAPI

A production-grade REST API deployed on AWS EKS with full CI/CD and monitoring.
Explore the repo »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Architecture
  3. Getting Started
  4. Usage
  5. CI/CD Pipeline
  6. Monitoring
  7. Acknowledgments

About The Project

A fully containerized Notes REST API built with Node.js and PostgreSQL, deployed to a Kubernetes cluster on AWS EKS. The project demonstrates end-to-end cloud engineering, from infrastructure provisioning with Terraform to automated deployments via GitHub Actions and real-time monitoring with Prometheus and Grafana.

Key highlights:

  • Infrastructure provisioned entirely with Terraform(VPC, EKS cluster, IAM roles, and Kubernetes resources)
  • Automated CI/CD pipeline that builds, tags, and deploys on every push to main
  • Prometheus and Grafana monitoring deployed to the cluster via Helm
  • Containerized with Docker and orchestrated with Kubernetes

(back to top)

Built With

  • Node.js
  • PostgreSQL
  • Docker
  • Kubernetes
  • Terraform
  • AWS
  • GitHub Actions

(back to top)


Architecture

Architecture Diagram

(back to top)


Getting Started

Prerequisites

Local Setup

  1. Clone the repo

    git clone https://github.com/KRC00112/notesAPI.git
    cd notesAPI
  2. Start the app and database

    docker compose up --build
  3. API is available at http://localhost:5000

Deploy to AWS

  1. Provision infrastructure

    cd terraform
    terraform init
    terraform apply
  2. Update your kubeconfig

    aws eks update-kubeconfig --region us-west-2 --name <cluster-name>
  3. Verify the cluster is accessible

    kubectl get nodes

    kubectl get nodes

  4. Create the notes table

    kubectl exec -it deployment/postgres-deployment -- /bin/sh
    psql -U postgres
    \c notesdb
    CREATE TABLE notes (note_id SERIAL PRIMARY KEY, created_at TIMESTAMP DEFAULT NOW(), note VARCHAR(255) NOT NULL);
  5. Install Prometheus and Grafana monitoring

    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    helm repo update
    helm install prometheus prometheus-community/kube-prometheus-stack \
      --namespace monitoring --create-namespace

(back to top)


Usage

Method Endpoint Description
GET / Get all notes
GET /:id Get a note by ID
POST / Create a new note
PUT /:id Update a note
DELETE /:id Delete a note

Example - create a note:

curl -X POST http://<load-balancer-url>:5000/ -H "Content-Type: application/json" -d '{"note": "my first note"}'

Example - get all notes:

curl http://<load-balancer-url>:5000/

(back to top)


CI/CD Pipeline

Two GitHub Actions workflows handle automated deployment:

CI (ci.yaml) - triggers on every push to main:

  1. Log in to Docker Hub
  2. Build the image via Docker Compose
  3. Tag with the commit SHA and push to Docker Hub

CD (cd.yaml) - triggers when CI completes successfully:

  1. Configure AWS credentials
  2. Update kubeconfig for the EKS cluster
  3. Deploy the new image with kubectl set image using the exact commit SHA
  4. Wait for rollout to complete

Using commit SHA tags instead of latest ensures Kubernetes always pulls the exact image that was just built, avoiding caching issues.

GitHub Actions Secrets Required

Secret Description
DOCKERHUB_USERNAME Docker Hub username
DOCKERHUB_TOKEN Docker Hub access token
AWS_ACCESS_KEY_ID AWS IAM access key ID
AWS_SECRET_ACCESS_KEY AWS IAM secret access key
EKS_CLUSTER_NAME EKS cluster name from Terraform output

(back to top)


Monitoring

Prometheus and Grafana are deployed to the monitoring namespace via the kube-prometheus-stack Helm chart. Metrics are automatically scraped from all cluster workloads including the notesapi pods.

Access Grafana locally:

kubectl port-forward -n monitoring svc/prometheus-grafana 3000:80

Open http://localhost:3000. The default login username is admin and retrieve password with:

kubectl get secret -n monitoring prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 --decode

Access Prometheus locally:

kubectl port-forward -n monitoring svc/prometheus-kube-prometheus-prometheus 9090

Open http://localhost:9090

Grafana Cluster Grafana Pods Grafana Network Prometheus Query

(back to top)


Acknowledgments

(back to top)

About

Production-grade Notes REST API on AWS EKS with Terraform, Kubernetes, CI/CD automation, and Prometheus/Grafana monitoring.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors