A complete DevOps CI/CD pipeline demonstration project featuring Python Flask application, Docker containerization, Kubernetes deployment with Helm, ArgoCD GitOps, and automated GitHub Actions workflows.
- Overview
- Architecture
- Features
- Prerequisites
- Quick Start
- Project Structure
- Development
- Deployment
- GitFlow Workflow
- CI/CD Pipeline
- Documentation
This project demonstrates a modern DevOps workflow implementing:
- Python Flask Application: RESTful API with health checks
- Container Orchestration: Docker multi-stage builds
- Kubernetes Deployment: Helm charts with best practices
- GitOps: ArgoCD for automated deployments
- CI/CD: GitHub Actions for build, test, and deploy
- GitFlow: Branch-based development workflow
- Automated Testing: Unit tests with pytest and coverage
βββββββββββββββ
β Git Repo β
β (GitHub) β
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββ
β GitHub Actions β β CI/CD Pipeline
β - Build β
β - Test β
β - Push Image β
ββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββ
β GitHub Registry β β Container Storage
β (GHCR) β
ββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββ
β ArgoCD β β GitOps Controller
β (Kubernetes) β
ββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββ
β Kubernetes β β Production Environment
β with Helm β
βββββββββββββββββββ
- β RESTful API endpoints
- β Health and readiness probes
- β Structured logging
- β Error handling
- β Environment-based configuration
- β Multi-stage Docker builds
- β Kubernetes-ready Helm charts
- β Horizontal Pod Autoscaling (HPA)
- β ArgoCD GitOps deployment
- β Automated CI/CD with GitHub Actions
- β GitFlow workflow enforcement with Git hooks
- β Automated testing and code coverage
- β Container image signing and attestation
- β GitHub Copilot integration in Git hooks
- Python 3.11+
- Docker (install manually from https://docs.docker.com/get-docker/)
- kubectl (for Kubernetes)
- Helm (for Kubernetes package management)
- uv (Python package manager)
- k9s (optional, for Kubernetes cluster management)
Run the init script to install all required tools:
chmod +x scripts/init.sh
./scripts/init.shConfigure Git hooks for GitFlow enforcement:
chmod +x .githooks/setup.sh
./.githooks/setup.shOr install tools individually:
chmod +x scripts/*.sh
./scripts/install-uv.sh
./scripts/install-kubectl.sh
./scripts/install-helm.sh
./scripts/install-k9s.sh
./scripts/install-argocd.sh # Optionalgit clone https://github.com/nirgeier/DevOps-Demo-Project.git
cd DevOps-Demo-Project
./scripts/init.sh# Activate virtual environment
source .venv/bin/activate
# Run the application
python app/main.py
# Or with gunicorn (production-like)
gunicorn --bind 0.0.0.0:8080 app.main:appVisit: http://localhost:8080
# Build the image
docker build -f docker/Dockerfile -t ghcr.io/nirgeier/devops-demo-project:latest .
# Run the container
docker run -p 8080:8080 ghcr.io/nirgeier/devops-demo-project:latest
# Or use docker-compose
docker-compose -f docker/docker-compose.yml up -dValidate and package the Helm chart for Kubernetes deployment:
# Lint the Helm chart for errors
helm lint helm/devops-demo
# Template the chart to see generated Kubernetes manifests
helm template devops-demo helm/devops-demo
# Package the chart into a .tgz file
helm package helm/devops-demo
# Validate the packaged chart
helm lint devops-demo-*.tgz
# Uninstall previous release if exists
helm uninstall devops-demo-test --namespace devops-demo || true
# Test the chart installation (dry-run)
helm install devops-demo-test helm/devops-demo --namespace devops-demo --create-namespace
# Clean up test package
rm devops-demo-*.tgzHelm Chart Details:
| Property | Description |
|---|---|
| Chart Name | devops-demo |
| Version | Defined in helm/devops-demo/Chart.yaml |
| Values | Configurable via helm/devops-demo/values.yaml |
| Templates | Kubernetes manifests in helm/devops-demo/templates/ |
Common Helm Commands:
# List all releases
helm list -A
# Get release status
helm status devops-demo
# Upgrade release
helm upgrade devops-demo helm/devops-demo --namespace devops-demo
# Rollback release
helm rollback devops-demo --namespace devops-demo
# Uninstall release
helm uninstall devops-demo --namespace devops-demo# Install with Helm, updating or installing as needed
helm upgrade \
--install devops-demo helm/devops-demo \
--namespace devops-demo \
--create-namespace \
--values helm/devops-demo/values.yaml
# Or use ArgoCD
kubectl apply -f argocd/namespace.yaml
kubectl apply -f argocd/application.yamlDevOps-Demo-Project/
βββ app/ # Python application
β βββ __init__.py
β βββ main.py # Flask application
βββ tests/ # Test suite
β βββ __init__.py
β βββ test_main.py # Unit tests
βββ docker/ # Docker configuration
β βββ Dockerfile # Multi-stage build
β βββ .dockerignore
β βββ docker-compose.yml
βββ helm/ # Helm charts
β βββ devops-demo/
β βββ Chart.yaml
β βββ values.yaml
β βββ templates/ # Kubernetes manifests
βββ argocd/ # ArgoCD configuration
β βββ application.yaml
β βββ namespace.yaml
β βββ README.md
βββ scripts/ # Installation scripts
β βββ init.sh # Project initialization
β βββ install-uv.sh
β βββ install-kubectl.sh
β βββ install-helm.sh
β βββ install-k9s.sh
βββ .githooks/ # Git hooks for GitFlow
β βββ pre-commit # Branch protection & checks
β βββ commit-msg # Commit message validation
β βββ pre-push # Branch naming validation
β βββ setup.sh # Hooks installation script
β βββ README.md # Hooks documentation
β βββ workflows/
β βββ ci.yml # Continuous Integration
β βββ cd.yml # Continuous Deployment
β βββ release.yml # Release management
β βββ gitflow.yml # GitFlow validation
βββ docs/ # Documentation
βββ pyproject.toml # Python dependencies
βββ .gitignore
βββ README.md
# Run all tests
pytest tests/ -v
# With coverage report
pytest tests/ -v --cov=app --cov-report=html
# View coverage report
open htmlcov/index.html# Linting
flake8 app/ tests/
# Formatting
black app/ tests/# Create virtual environment
uv venv
# Activate environment
source .venv/bin/activate
# Install dependencies
uv pip install -e ".[dev]"
# Run development server
python app/main.py# Build multi-platform image
docker buildx build --platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t ghcr.io/nirgeier/devops-demo-project:latest \
--push .# Using Helm
helm upgrade --install devops-demo helm/devops-demo \
--namespace devops-demo \
--create-namespace \
--values helm/devops-demo/values.yaml
# Check deployment
kubectl get pods -n devops-demo
kubectl get svc -n devops-demo
# Port forward for local access
kubectl port-forward -n devops-demo svc/devops-demo 8080:80# Install ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Deploy application
kubectl apply -f argocd/namespace.yaml
kubectl apply -f argocd/application.yaml
# Access ArgoCD UI
kubectl port-forward svc/argocd-server -n argocd 8080:443This project follows the GitFlow branching model:
main- Production-ready codedevelop- Integration branch for featuresfeature/*- New features (branch from develop)release/*- Release preparation (branch from develop)hotfix/*- Production fixes (branch from main)
-
Feature Development
git checkout develop git checkout -b feature/new-feature # ... make changes ... git push origin feature/new-feature # Create PR to develop
-
Release Process
git checkout develop git checkout -b release/1.0.0 # ... update version, changelog ... git push origin release/1.0.0 # Create PR to main
-
Hotfix
git checkout main git checkout -b hotfix/critical-fix # ... fix issue ... git push origin hotfix/critical-fix # Create PR to main
Triggered on: Push to any branch, Pull Requests
Steps:
- β Code checkout
- β Python setup with uv
- β Install dependencies
- β Run linting (flake8)
- β Run tests with coverage
- β Build Docker image
- β Test Docker image
Triggered on: Push to main, Version tags
Steps:
- β Build multi-platform Docker image
- β Push to GitHub Container Registry
- β Generate image attestation
- β Create GitHub release (for tags)
- β Update GitOps repository
Automated release workflow:
- Create release branch
- Automatic PR to main
- On merge: Create version tag
- Trigger CD pipeline
- Merge back to develop
- Git Hooks Guide - π£ GitFlow enforcement with Copilot
- ArgoCD Setup
- Helm Charts
- API Documentation
- Deployment Guide
- GitFlow Workflow
- GitHub Copilot Resources - π€ AI-powered development assistance
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Welcome message |
/health |
GET | Health check |
/ready |
GET | Readiness probe |
/api/info |
GET | Application information |
/api/echo |
POST | Echo endpoint |
- Python/Flask - Application framework
- uv - Fast Python package manager
- Docker - Containerization
- Kubernetes - Container orchestration
- Helm - Kubernetes package manager
- ArgoCD - GitOps continuous delivery
- GitHub Actions - CI/CD automation
- pytest - Testing framework
- k9s - Kubernetes CLI manager
MIT License - see LICENSE file for details
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For questions or support, please open an issue on GitHub.
Made with β€οΈ for DevOps Engineers DevOps-Demo-Project