This project demonstrates deploying a microservices-based FastAPI e-commerce application using modern DevOps tooling and best practices:
- Microservices: users and products services built with FastAPI.
- Containerization: Docker for packaging apps.
- Orchestration: Kubernetes (Minikube) for deployment and scaling.
- Configuration Management: Helm charts for templating Kubernetes manifests.
- Infrastructure as Code: Terraform for provisioning cloud resources.
- Monitoring & Observability: Prometheus + Grafana for metrics; ELK Stack for logging.
- CI/CD: Automated pipelines for build, test, and deployment.
- Microservices architecture with independent services for users, products, and more
- Authentication with OAuth (Google, GitHub)
- Role-based access control (Admin, Staff, Customer roles)
- PostgreSQL or SQLite database support via SQLAlchemy ORM
- JWT token authentication
- Dockerized services for consistent environments
- Kubernetes manifests for container orchestration
- Terraform integration for cloud infrastructure (planned)
- Docker
- Minikube & kubectl
- Helm
- Terraform
- Prometheus + Grafana (Optional)
- ELK Stack (Optional)
-
Clone the repo:
git clone https://github.com/madhvi-n/fastapi-ecommerce-microservice-devops.git cd fastapi-ecommerce-microservice-devops
-
Environment variables Refer to
services/users/.env.example
for required variables like:
DATABASE_URL
JWT_SECRET_KEY
GOOGLE_CLIENT_ID
Build service images locally:
docker build -t users-service:latest -f ./services/users/Dockerfile .
docker build -t products-service:latest -f ./services/products/Dockerfile .
Load images into Minikube’s Docker daemon:
minikube image load users-service
minikube image load products-service
2. Deploy with Kubernetes K8 deployment guide
Apply base Kubernetes manifests (deployments, services, configmaps, secrets):
kubectl apply -f k8s/base
Use Helm charts for easier management Helm deployment guide
helm install users ./helm-chart/users
helm install products ./helm-chart/products
Use ingress Ingress deployment guide
kubectl apply -f ingress.yaml
# Check if ingress is created
kubectl get ingress
# Check if ingress is running
kubectl get pods -n ingress-nginx
Now you can access your services from your browser:
http://app.local/users
http://app.local/products
Use Terraform to provision cloud infrastructure resources (e.g., AWS S3 buckets, databases, etc.):
terraform init
terraform apply
- Prometheus + Grafana: Monitor app and cluster metrics with real-time dashboards.
- ELK Stack: Centralized log collection and analysis across services.
# Kubernetes commands
kubectl get pods
kubectl get svc
kubectl logs <pod-name>
kubectl port-forward service/nginx-service 8080:80
# Helm commands
helm install ecommerce ./helm-chart
helm upgrade ecommerce ./helm-chart
helm uninstall ecommerce
# Terraform commands
terraform init
terraform plan
terraform apply
terraform destroy
# Docker commands
docker build -t users-service:latest ./services/users
docker push <registry>/users-service:latest
docker-compose up
docker-compose build
docker-compose down
- Containerize microservices for consistent environments.
- Orchestrate deployment, scaling, and management of containers.
- Package and manage Kubernetes manifests as charts for templating and reusability.
- Infrastructure as code to provision and manage cloud resources.
- Monitor system and application metrics with dashboards and alerts.
- Centralized logging and visualization for troubleshooting and auditing.
- Automate build, test, and deployment for rapid and reliable delivery.
- GitHub Actions or Jenkins for CI/CD
- Docker Hub or GitHub Container Registry
- Istio or Linkerd for service mesh
- ELK stack (Elasticsearch, Logstash, Kibana) or Loki or Jaeger for logging/tracing
- Vault or Sealed Secrets for secret management
- Ansible, Chef, Puppet for Configuration management