This is a sample FastAPI project prepared for development, testing, containerization, and deployment to a Kubernetes cluster using modern DevOps tools.
.
├── src/ # Application source code
│ └── main.py
├── tests/ # Pytest unit tests
├── Dockerfile # Docker build definition
├── requirements.txt
├── .env # Environment variables
├── helm/ # Helm chart for Kubernetes deployment
├── workflow/ # Argo Workflows YAML files
├── .github/workflows/ # GitHub CI/CD workflows
├── Makefile # DevOps automation commands
└── README.md
make install-devuvicorn src.main:app --reloadmake testmake pipreqsdocker build -t fastapi-app .
docker run -p 8000:8000 --env-file .env fastapi-appBefore you can deploy, make sure the following tools are installed:
helm install fastapi-app helm/ --namespace fastapi --create-namespaceLiveness and readiness probes are configured in values.yaml.
- CI: GitHub Actions for building, linting, and testing
- CD: Argo Workflows + Argo CD for automated deployment to the cluster
Tests are written using pytest and run with:
make testMonitoring is enabled using:
kube-prometheus-stack(Prometheus, Grafana, Alertmanager)- Access dashboards with:
minikube service prometheus -n monitoring minikube service grafana -n monitoring
This project uses pre-commit. Install with:
pre-commit installHooks include:
- Isort
- Helm lint
- Yaml check
| Command | Description |
|---|---|
make install-dev |
Set up virtual environment & install dev deps |
make build |
Build the Docker image |
make test |
Run tests |
make helm-deploy |
Deploy the Helm chart to Kubernetes |
make precommit |
Run all pre-commit hooks locally |
make help |
List all commands |
kubectl port-forward svc/argocd-server -n argocd 8080:443- Open: https://localhost:8080
- Get the initial password:
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d