Applications Python — Vue d'ensemble
Trois applications Python déployées sur le cluster k3s via GitOps (ArgoCD). Chaque application suit le même cycle de vie : développement → CI/CD → scan → déploiement.
Applications
| Application | Stack | URL | Réplicas |
|---|---|---|---|
| FastAPI | FastAPI + uvicorn + Prometheus | app-fastapi.mounik.ovh |
2 |
| Streamlit | Streamlit + pandas + plotly | app-streamlit.mounik.ovh |
2 |
| Flask | Flask + Jinja2 + Bootstrap | app-flask.mounik.ovh |
2 |
Cycle de vie
1. Push code → GitLab.com
2. Pipeline CI/CD (test → sast → build → scan → push → dast → deploy)
3. Image poussée sur Harbor (harbor.mounik.ovh)
4. Manifest Kubernetes mis à jour (tag image)
5. ArgoCD détecte le changement et synchronise
6. Application accessible via app-*.mounik.ovh
Structure d'un projet
app-name/
├── .gitlab-ci.yml # Pipeline CI/CD DevSecOps
├── Dockerfile # Python 3.13-slim
├── requirements.txt # Dépendances
├── app/
│ └── main.py # Code application
├── tests/
│ └── test_main.py # Tests pytest
└── manifests/
├── deployment.yaml # Déploiement Kubernetes
├── service.yaml # Service ClusterIP
└── ingress.yaml # Ingress Traefik
Déploiement GitOps
Les manifests Kubernetes sont dans le dépôt homelab-proxmox/manifests/apps/ :
homelab-proxmox/manifests/apps/
├── fastapi/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── ingress.yaml
├── streamlit/
│ └── ...
└── flask/
└── ...
ArgoCD synchronise automatiquement chaque dossier avec le namespace correspondant sur k3s.
Dockerfile générique
FROM python:3.13-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
CI/CD
Chaque application partage le même pipeline DevSecOps (détaillé dans la Phase 7 — DevSecOps) :
- test : pytest, ruff, mypy
- sast : Semgrep + Bandit → DefectDojo
- build : Docker build
- scan : Trivy → DefectDojo
- push : Harbor
- dast : OWASP ZAP → DefectDojo
- deploy : Mise à jour manifest + ArgoCD sync
Pour aller plus loin
- FastAPI — API REST Python
- Streamlit — dashboard data
- Flask — application web simple
- Phase 6 — Applications — déploiement complet