A microservices-based checkout workflow running on Kubernetes (K3s) with KEDA autoscaling, circuit breakers, structured logging, request correlation and PostgreSQL persistence.
Built with Python/FastAPI. Extends the Lab 9/12 patterns (gateway → checkout → pricing + inventory) with six production-grade enhancements.
Browser → Traefik Ingress → Gateway → Checkout → [Pricing, Inventory] + PostgreSQL
Four FastAPI microservices running on K3s with KEDA autoscaling, structured JSON logging, and X-Request-Id correlation.
- Ubuntu 22.04 VM (VirtualBox)
- Docker, K3s, Helm, KEDA installed
chmod +x scripts/*.sh
./scripts/build.sh
for f in k8s/[0-9]*.yaml; do kubectl apply -f "$f"; done- UI: http://localhost/ (or http://localhost:8080/ via NAT port forward)
- Health: http://localhost/health
- Architecture: http://localhost/api/arch
- Ping: http://localhost/api/ping
- Checkout: POST http://localhost/api/checkout
./scripts/test-functional.sh
./scripts/test-reliability.sh
./scripts/test-scaling.sh| ID | Name | Price | Stock |
|---|---|---|---|
| WM-100 | Wireless Mouse | €29.99 | 42 |
| BH-200 | Bluetooth Headphones | €49.99 | 15 |
| UC-300 | USB-C Cable | €9.99 | 100 |
| MK-400 | Mechanical Keyboard | €199.99 | 3 |
| PS-500 | Phone Stand | €14.50 | 0 |
- Structured JSON logging: machine-parseable, every line has request_id
- Circuit breaker (pybreaker): opens after 3 failures, 30s recovery
- Retry with backoff: 2 retries at 0.5s, 1s intervals
- Fallback pricing: cached prices when pricing-svc is down
- Startup probe: 30s boot window before K8s considers it failed
- Readiness endpoint: /ready checks actual PostgreSQL connectivity
- All FastAPI containers run as non-root (appuser, UID 1000)
- PostgreSQL credentials managed via Kubernetes Secret (stringData)
- PostgreSQL runs as default postgres user (documented exception) ENDOFREADME