An end-to-end local DevOps pipeline that builds, scans, and deploys two FastAPI microservices to a kind (Kubernetes-in-Docker) cluster, driven entirely by Jenkins. The pipeline runs static code analysis with SonarQube, image vulnerability scanning with Trivy, and deploys via versioned Helm charts across nonprod and prod namespaces — with a manual approval gate before production release.
┌─────────────┐
git push --> │ Jenkins │
└──────┬──────┘
│
┌──────────────┼───────────────┐
▼ ▼ ▼
Build Images SonarQube Scan Trivy Image Scan
(users/orders) + Quality Gate (HIGH/CRITICAL)
│ │ │
└──────────────┴───────────────┘
│
kind load docker-image
│
▼
Helm upgrade --install
│
┌─────────────┴─────────────┐
▼ ▼
nonprod namespace prod namespace
(auto-deploy) (manual approval gate)
Two independent FastAPI services are deployed using the same generic Helm chart, parameterized per service and per environment via separate values-*.yaml files.
.
├── app1/ # Users microservice (FastAPI)
│ ├── main.py
│ ├── Dockerfile
│ └── requirements.txt
├── app2/ # Orders microservice (FastAPI)
│ ├── main.py
│ ├── Dockerfile
│ └── requirements.txt
├── helm/
│ ├── fastapi-app/ # Generic, reusable Helm chart
│ │ ├── Chart.yaml
│ │ ├── values.yaml
│ │ └── templates/
│ │ ├── deployment.yaml
│ │ ├── service.yaml
│ │ ├── ingress.yaml
│ │ └── _helpers.tpl
│ ├── values-users.yaml # Per-service base values
│ ├── values-users-nonprod.yaml
│ ├── values-users-prod.yaml
│ ├── values-orders.yaml
│ ├── values-orders-nonprod.yaml
│ └── values-orders-prod.yaml
├── kind-config.yaml # kind cluster config (ingress-ready, ports 80/443 mapped)
├── pipeline script of non prod.txt # Jenkinsfile: build → scan → deploy to nonprod
├── prod namespace/
│ └── pipeline jenkins script.txt # Jenkinsfile: build → manual approval → deploy to prod
├── sonar-report-*.html / sonar-metrics-*.json # Archived SonarQube reports per build
├── trivy-*-service-*.json / .txt # Archived Trivy scan reports per build
├── non prod/, prod namespace/ # Deployment logs & resource dumps (proof of successful runs)
├── kind cluster installation proof/
├── sonarqube installation and implementation/
└── helm installation/
| Service | Path | Port | Key Endpoints |
|---|---|---|---|
| users-service | app1/ |
8000 | /, /healthz, /readyz, /users |
| orders-service | app2/ |
8000 | /, /healthz, /readyz, /orders |
Both are minimal FastAPI apps (fastapi==0.115.0, uvicorn[standard]==0.30.6) built on python:3.12-slim, running as a non-root appuser, and expose /healthz and /readyz for Kubernetes liveness/readiness probes.
- Build Images — Docker builds
users-serviceandorders-service, tagged with the JenkinsBUILD_NUMBER. - SonarQube Analysis — Runs
sonar-scanner-cliagainst both service source directories. - Quality Gate — Pipeline aborts if SonarQube's quality gate fails.
- Generate SonarQube Report — Produces an HTML report and a JSON metrics snapshot (bugs, vulnerabilities, code smells, coverage, duplication, LOC) per build.
- Trivy Scan — Scans both images for
HIGH/CRITICALvulnerabilities, archiving JSON and table-format reports. - Load Images into Kind —
kind load docker-imagepushes the built images directly into the local cluster (no external registry needed). - Deploy to
nonprod—helm upgrade --installfor both services using their nonprod values files. - Verify — Confirms pods, services, and ingress are healthy in the
nonprodnamespace.
- Build Images
- Load Images into Kind
- Manual Approval Gate —
inputstep pauses the pipeline, requiring explicit confirmation before deploying to production. - Deploy to
prod—helm upgrade --installfor both services using their prod values files. - Verify — Confirms pods, services, and ingress in the
prodnamespace.
A single generic chart (helm/fastapi-app) is reused for both services and both environments. Per-service, per-environment behavior is controlled entirely through values files:
image.repository/image.tag— which image to deployingress.host— e.g.users-nonprod.local,orders-prod.localreplicaCount,resources— scaling and limitslivenessProbe/readinessProbe— wired to/healthzand/readyz
Example deploy command used in the pipeline:
helm upgrade --install users-service ./helm/fastapi-app \
-f ./helm/values-users-nonprod.yaml \
--set image.tag=${IMAGE_TAG} \
--namespace nonprod --create-namespace \
--wait --timeout 180sThe kind-config.yaml provisions a single control-plane node labeled ingress-ready=true, with host ports 80 and 443 mapped in — ready for an NGINX ingress controller.
kind create cluster --config kind-config.yaml --name devops-demo- App: Python, FastAPI, Uvicorn
- Containerization: Docker
- Orchestration: Kubernetes (kind), Helm
- CI/CD: Jenkins (declarative pipeline)
- Code Quality: SonarQube (quality gate enforced)
- Security Scanning: Trivy (image vulnerability scanning)
- Ingress: NGINX Ingress Controller
This repository includes archived pipeline run artifacts (build logs, SonarQube reports, Trivy scan outputs, kubectl get all dumps) as evidence of successful end-to-end pipeline execution across both nonprod and prod namespaces.