Skip to content

sudarshan-rp/User-data-store

Repository files navigation

User Data Store - Kubernetes Application (EKS Deployment)

The User Data Store is a FastAPI-based microservice that exposes a RESTful API for managing user data, connected to a PostgreSQL backend. It is deployed on Amazon Elastic Kubernetes Service (EKS) with infrastructure provisioned using IaC (Infrastructure as Code) and automated deployment pipelines via GitHub Actions.

This is the production-ready deployment of the User Data Store application using Amazon EKS, FastAPI, PostgreSQL, and GitHub Actions for automated CI/CD. This branch is optimized for cloud-native scalability, reliability, and observability using Kubernetes best practices.


🚧 Under Active Development 🚧

Status

This repository is a work in progress. Expect frequent updates, breaking changes, and evolving features.


📐 Architecture Diagram (EKS)

User Data Store drawio

⚙️ Technologies Used

FastAPI PostgreSQL Amazon EKS GitHub Actions Docker Kubernetes kubectl AWS CloudWatch IaC – User‑data‑IaC

  • IaC – EKS infrastructure created using GitHub repo: ➡️ User-data-IaC

⚡ Quick Start

1. ✅ Prerequisites

  • AWS account with EKS permissions
  • EKS cluster created using the IaC repo
  • kubectl configured to point to the correct cluster
  • GitHub Actions secrets configured:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_REGION
    • EKS_CLUSTER_NAME
    • ECR_REGISTRY_URI

2. 🚀 Automated Deployment (via GitHub Actions )

Pushing to this branch triggers a GitHub Actions workflow that:

  1. Builds Docker image for backend
  2. Pushes it to Amazon ECR
  3. Applies Kubernetes manifests (/k8s/*.yaml)
  4. Verifies successful deployment Monitor progress under the "Actions" tab in GitHub.

3. 🚀 Manual Deployment (if needed)

# Set KUBECONFIG to EKS cluster
aws eks update-kubeconfig --region <region> --name <cluster-name>

# Apply manifests in order
kubectl apply -f k8s/pvc-eks.yaml
kubectl apply -f k8s/pg16.yaml
kubectl apply -f k8s/backend.yaml

4. 🔎 Access the App

# Forward port from service to localhost
kubectl port-forward -n myapp service/backend-service 8008:8008

# Access API documentation
http://localhost:8008/docs

📁 Project Structure

├── backend/                    # FastAPI application backend
│   ├── __init__.py
│   ├── main.py                # Application entry point and FastAPI app creation
│   ├── api/                   # API layer
│   │   └── routes/            # API route definitions
│   │       ├── health_routes.py    # Health check endpoints
│   │       └── user_routes.py      # User management endpoints
│   ├── db/                    # Database layer
│   ├── models/                # Data models
│   └── services/              # Business logic layer
├── k8s/                       # Kubernetes manifests
│   ├── backend.yaml           # Backend deployment and service
│   ├── pg16.yaml              # PostgreSQL 16 deployment, service, and secrets
│   ├── pvc.yaml               # Persistent Volume Claim for standard storage
│   └── pvc-eks.yaml           # PVC for EKS clusters
├── .github/                   # GitHub workflows for automated deployment
├── Dockerfile                 # Multi-stage Docker build
├── requirements.txt           # Python dependencies
├── .dockerignore             # Docker build exclusions
└── .gitignore                # Git exclusions

⚙️ Environment Variables

POSTGRES_HOST=postgres-service
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=testdb
DATABASE_URL=postgresql://postgres:postgres@postgres-service:5432/testdb

These are injected into the container via Kubernetes ConfigMaps or directly in the manifest.


🔍 Monitoring, Logs, Debugging

# Check pod status
kubectl get pods -n myapp

# Get logs from backend
kubectl logs -n myapp deployment/backend

# Get logs from DB
kubectl logs -n myapp deployment/postgres-db

For more debugging tools and techniques, refer to the Wiki


📚 Additional Documentation

Backend Architecture

Best-Practices

Troubleshooting

Additional References

Contributing Guide

About

An Application which store and manages user info.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •