How abeqqalmarouane/devops-capstone-project works
Project Type and Purpose
• This is a standalone RESTful microservice template built with Python 3.9 and Flask.
• It implements CRUD operations on an Account model (MVC pattern), backed by a Postgres database.
• It’s designed for DevOps capstone exercises: containerized development, CI/CD via Tekton, and Kubernetes deployment.
High-Level File Structure
• /service – Flask app package
– models.py (Model & DB logic)
– routes.py (Controller/REST API)
– common/ (error handlers, logging, CLI commands)
– config.py (Flask configuration)
• /tests – unit tests for CLI, models, routes (TDD style)
• /bin – environment setup script
• /deploy – Kubernetes/Postgres templates
• tekton/ – Tekton Pipeline, Tasks, PVC definitions
• .devcontainer/ – VSCode Remote-Container definitions
• Makefile, Procfile, requirements.txt – build, run, and dependency specs
Key Architectural Insights from README
• MVC separation: Models ↔ Routes
• Dockerized Postgres for local dev (make db)
• Local K3D Kubernetes + Tekton for CI/CD
• Target: ≥95% code coverage via TDD
a. Developer Environment
– VSCode Remote Container (.devcontainer)
– Local virtualenv (bin/setup.sh)
b. Source Control & CI/CD
– GitHub Repo (push triggers Tekton)
– Tekton Pipeline
• Tasks: lint, test, build Docker image, push to registry
• PVC for Postgres data in CI/CD cluster
c. Container Registry
– Holds built Flask service image
d. Kubernetes Cluster
– Deployment of:
1. Flask Service Pod (environment variables from ConfigMap/Secrets)
2. Postgres Pod (PVC from pvc.yaml)
– Service (ClusterIP/LoadBalancer) routing traffic to Flask Pod
e. External Clients
– CURL/HTTP clients consuming the REST API
Interactions and Data Flow
1. Developer codes → commits to GitHub
2. GitHub webhook → Tekton Pipeline
3. Pipeline Tasks execute in order:
a. pip install & make test → unit tests (95% coverage)
b. Lint & security scans
c. Build Docker image → push to registry
d. Apply K8s manifests (deploy/ + Tekton deploy tasks)
4. Kubernetes deploys Flask + Postgres Pods
5. Flask service connects to Postgres via SQLAlchemy (Model layer)
6. External REST clients ↔ Flask routes ↔ Models ↔ DB
Architectural Patterns & Principles
• MVC: clear separation of concerns
• Twelve-Factor App: config in environment, backing services as attached resources
• Immutable Infrastructure: container images, declarative K8s manifests
• CI/CD as code: Tekton YAML files under version control