Skip to content

This is a simple and scalable ToDo API built with Python FastAPI and PostgreSQL for storage, containerized using Docker, deployed on Kubernetes using Helm or Kustomizer.

Notifications You must be signed in to change notification settings

soumiknandi/fast-api-rest

Repository files navigation

📝 FastAPI ToDo App with Docker, Kubernetes, Argo CD, Kustomizer & Helm

This is a simple and scalable ToDo API built with Python FastAPI and PostgreSQL for storage, containerized using Docker, deployed on Kubernetes using Helm or Kustomizer.

🔧 Tech Stack

  • 🐍 Python FastAPI – Lightweight, high-performance REST API

  • 🐘 PostgreSQL – Relational database for persistent ToDo storage

  • 🐳 Docker – Containerization for easy deployment

  • ☸️ Kubernetes – Container orchestration

  • 🚀 Argo CD – GitOps-based continuous delivery

  • 🛠️ Helm – Kubernetes manifest templating

📂 Project Structure

.
├── src/
│   ├── main.py              # App code starting point
│   ├── Dockerfile           # Docker setup for the app
│   └── requirements.txt
├── .github/                 # GitHub Actions folder
├── kustomization/           # Kubernetes deployment and service YAMLs
├── helm/                    # Helm charts
├── charts/                  # Helm charts repo
├── docker-compose/          # Docker compose file for the app
├── helmfile.yaml            # Helmfile to deploy helm charts using repo URL
├── helmfileGit.yaml         # Helmfile to deploy helm charts using git URL
├── README.md

🚀 Features

  • RESTful API endpoints for create, read, update, delete ToDo items

  • Persistent storage using PostgreSQL

  • Dockerized for easy local and cloud deployment

  • Kubernetes manifests for both API and DB

  • Auto-generated Swagger UI documentation

📦 Setup (Locally with Docker)

docker compose up

Access the app at: http://localhost:8000

☸️ Deploy on Kubernetes (Minikube / Cluster)

kubectl apply -k kustomization/overlays/dev

🚀 Argo CD

Use below command to run using ARGO CD or via GUI.

argocd app create fast-api-rest-prod \
--repo https://github.com/soumiknandi/fast-api-rest.git \
--path kustomization/overlays/prod \
--dest-server https://kubernetes.default.svc \
--dest-namespace fast-api-rest-prod \
--sync-option CreateNamespace=true \
--sync-policy automated

🛠️ Helm

Steps to follow

  • Run helm package command

    cd helm
    helm dependency update fastapi-postgres
  • Run below command from project root based on the environment

    • Base

      helm install release-fast-api helm/ --values helm/values.yaml -n fast-api-rest --create-namespace
    • Dev

      helm install release-fast-api helm/ --values helm/values.yaml -f helm/values-dev.yaml -n fast-api-rest-dev --create-namespace
    • Prod

      helm install release-fast-api helm/ --values helm/values.yaml -f helm/values-prod.yaml -n fast-api-rest-prod --create-namespace

🌐 Hosted Helm Repo

How to create helm repo & host it?

  • Create helm package

    helm package ./helm --destination ./charts
  • Generate index.yaml

    cb charts
    helm repo index . --url https://soumiknandi.github.io/fast-api-rest/charts

Note

Github pages needs to be enabled in order to access the chart/repo URL.

How to use helm repo ?

  • Add the repo to helm
helm repo add fast-api-repo https://soumiknandi.github.io/fast-api-rest/charts
  • Run helm install
helm install release-fast-api-rest fast-api-chart/fast-api-rest-helm-chart -n fast-api-rest --create-namespace

📜 Helmfile

To run using helmfile use below command

helmfile sync

📄 API Documentation

FastAPI auto-generates:

  • Swagger UI: http://<host>:<port>/docs

✅ Todo

  • ARGO CD
  • GitHub Actions for CI
  • Helm

About

This is a simple and scalable ToDo API built with Python FastAPI and PostgreSQL for storage, containerized using Docker, deployed on Kubernetes using Helm or Kustomizer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published