A full-stack application (FastAPI backend + Next.js frontend + PostgreSQL) demonstrating how to deploy with Helm charts on Kubernetes.
This project showcases:
- FastAPI Backend with PostgreSQL database
- Next.js Frontend (React)
- Nginx reverse proxy
- Helm Charts for Kubernetes deployment
- Docker Compose for local development
hello-helm/
βββ backend/ # FastAPI application
β βββ app/ # Application code
β βββ Dockerfile # Dev dockerfile
β βββ Dockerfile.prod # Production dockerfile
β βββ pyproject.toml # Python dependencies (uv)
β
βββ frontend/ # Next.js application
β βββ (frontend code)
β
βββ nginx/ # Nginx configuration
β βββ (nginx config)
β
βββ helm_charts/ # Kubernetes Helm Charts
β βββ backend/ # Backend + PostgreSQL chart
β β βββ Chart.yaml
β β βββ values.yaml
β β βββ values-local.yaml
β β βββ templates/
β β β βββ deployment.yaml
β β β βββ service.yaml
β β β βββ postgres-statefulset.yaml
β β β βββ postgres-service.yaml
β β β βββ postgres-secret.yaml
β β βββ QUICK-START.md # 5-minute deployment guide
β β βββ README.md # Complete chart documentation
β β βββ STRUCTURE.md # Chart structure deep-dive
β β
β βββ frontend/ # Frontend chart
β βββ (similar structure)
β
βββ compose.yml # Docker Compose for local dev
β
βββ docs/ # Documentation
β βββ HELM-LEARNING-GUIDE.md # π Complete learning guide
β βββ DEPLOYMENT.md # Deployment instructions
β βββ DOCKER-COMPOSE-VS-HELM.md # Concept comparison
β βββ MAKEFILE-GUIDE.md # Makefile commands reference
β
βββ README.md # This file
docker-compose upAccess:
- Frontend: http://localhost:80
- Backend: http://localhost:80/api
- Backend docs: http://localhost:80/api/docs
Prerequisites:
- Docker
- Kubernetes (minikube/kind/Docker Desktop)
- Helm 3.x
- kubectl
Deploy in 3 commands:
# 1. Build & load image
cd backend
docker build -f Dockerfile.prod -t backend-app:latest .
minikube image load backend-app:latest # or: kind load docker-image backend-app:latest
# 2. Deploy with Helm
cd ../helm_charts/backend
helm install my-backend .
# 3. Access the application
kubectl port-forward svc/my-backend 8000:8000Visit: http://localhost:8000/docs
-
docs/HELM-LEARNING-GUIDE.md β
- Complete learning path (Beginner β Advanced)
- Understand Helm concepts
- Key takeaways and best practices
-
helm_charts/backend/QUICK-START.md
- Deploy in 5 minutes
- Perfect for first-time users
-
- Comprehensive deployment guide
- Step-by-step instructions
- Troubleshooting tips
-
docs/DOCKER-COMPOSE-VS-HELM.md
- Compare Docker Compose to Kubernetes/Helm
- Concept mapping
- When to use what
-
helm_charts/backend/STRUCTURE.md
- Deep dive into Helm chart structure
- Template syntax
- Values flow
- helm_charts/backend/README.md
- Complete chart documentation
- Configuration options
- Customization examples
βββββββββββββββββββββββββββββββββββββββ
β Docker Compose β
β βββββββββββ βββββββββββ β
β β Nginx β β Backend β β
β β :80 ββ β :8000 β β
β βββββββββββ ββββββ¬βββββ β
β βββββββββββ β β
β βFrontend β β β
β β :3000 β β β
β βββββββββββ ββββββββββββ β
β βPostgres β β
β β :5432 β β
β ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Kubernetes Cluster β
β β
β ββββββββββββββββββββ ββββββββββββββββββββββ β
β β Backend Deploy β β Frontend Deploy β β
β β ββββββββββββββββ β β ββββββββββββββββββ β β
β β β Pod β Pod β..ββ β β β Pod β Pod β... β β β
β β ββββββββββββββββ β β ββββββββββββββββββ β β
β ββββββββββ¬ββββββββββ ββββββββββββ¬ββββββββββ β
β β β β
β ββββββββββΌββββββββββ βββββββββββΌββββββββββ β
β β Backend Service β β Frontend Service β β
β β ClusterIP :8000 β β ClusterIP :3000 β β
β ββββββββββββββββββββ βββββββββββββββββββββ β
β β β
β ββββββββββΌββββββββββββββββββ β
β β PostgreSQL StatefulSet β β
β β ββββββββββββββββββββββββ β β
β β β postgres-0 β β β
β β ββββββββββββββββββββββββ β β
β ββββββββββ¬ββββββββββββββββββ β
β β β
β ββββββββββΌββββββββββ β
β β PVC (1Gi) β β
β ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
- FastAPI - Modern Python web framework
- SQLAlchemy - ORM with async support
- PostgreSQL 15 - Database
- Uvicorn - ASGI server
- Pydantic - Data validation
- uv - Fast Python package manager
- Next.js - React framework
- TypeScript - Type safety
- Tailwind CSS - Styling
- Docker - Containerization
- Kubernetes - Orchestration
- Helm - Package management
- Nginx - Reverse proxy
[project]
dependencies = [
"asyncpg>=0.30.0",
"fastapi[standard]>=0.118.0",
"pydantic>=2.11.10",
"pydantic-settings>=2.11.0",
"sqlmodel>=0.0.25",
"uvicorn>=0.37.0",
]-
Secrets Management
- Don't store passwords in
values.yaml - Use Kubernetes Secrets with encryption at rest
- Consider external secret managers (Vault, AWS Secrets Manager)
- Don't store passwords in
-
Image Security
- Use specific version tags, not
latest - Scan images for vulnerabilities
- Use minimal base images
- Use specific version tags, not
-
Network Security
- Implement Network Policies
- Use TLS/SSL for all connections
- Restrict service-to-service communication
-
Access Control
- Enable RBAC
- Use least privilege principle
- Regular security audits
# With Docker Compose
docker-compose up backend postgres
# Test endpoints
curl http://localhost:8000/health
curl http://localhost:8000/items
# API docs
open http://localhost:8000/docs# Deploy
helm install test-backend helm_charts/backend/
# Port forward
kubectl port-forward svc/test-backend 8000:8000
# Test
curl http://localhost:8000/health
# Cleanup
helm uninstall test-backend# View logs
docker-compose logs backend
docker-compose logs postgres
# Restart services
docker-compose restart backend
# Clean up
docker-compose down -v# Check pod status
kubectl get pods
# View logs
kubectl logs -l app.kubernetes.io/name=backend
# Describe pod for events
kubectl describe pod <pod-name>
# Delete and recreate
helm uninstall my-backend
helm install my-backend helm_charts/backend/See DEPLOYMENT.md for detailed troubleshooting.
# Docker Compose
docker-compose logs -f backend
# Kubernetes
kubectl logs -l app.kubernetes.io/name=backend -fFor production, consider adding:
- Prometheus - Metrics collection
- Grafana - Visualization
- Loki - Log aggregation
- Jaeger - Distributed tracing
Suggested pipeline:
1. Code Push
β
2. Run Tests
β
3. Build Docker Image
β
4. Push to Registry
β
5. Update Helm Values
β
6. Deploy to Staging
β
7. Run Integration Tests
β
8. Deploy to Production (manual approval)
- Edit code in
backend/app/ - Test locally with Docker Compose
- Build new image with version tag
- Update Helm values with new tag
- Deploy to dev cluster and test
- Deploy to production when ready
# 1. Make changes
vim backend/app/main.py
# 2. Test with compose
docker-compose up backend
# 3. Build with version
docker build -f backend/Dockerfile.prod -t backend-app:v1.2.3 .
# 4. Load into cluster
minikube image load backend-app:v1.2.3
# 5. Deploy
helm upgrade my-backend helm_charts/backend/ \
--set image.tag=v1.2.3This is a learning project following your company's Helm chart pattern:
- Each component gets its own chart
- Charts are independent and versioned separately
- Shared values through parent charts or external configuration
This is a practice/learning project.
- Check HELM-LEARNING-GUIDE.md for comprehensive guidance
- Review DEPLOYMENT.md for deployment issues
- Read component-specific READMEs in
helm_charts/ - Check troubleshooting sections in each guide
- Deploy backend with Helm β (follow QUICK-START.md)
- Create frontend Helm chart (similar pattern)
- Add Ingress for external access
- Set up monitoring (Prometheus/Grafana)
- Implement CI/CD pipeline
- Add automated tests
- Document runbooks for operations
Happy Learning! πβ
For a complete learning experience, start with docs/HELM-LEARNING-GUIDE.md!