A comprehensive hands-on laboratory for learning GitOps, Kubernetes, and DevOps best practices using a real-world TODO application. This project demonstrates modern cloud-native development workflows with automated CI/CD, infrastructure as code, and declarative deployment strategies.
- Overview
- Architecture
- Features
- Prerequisites
- Quick Start
- Project Structure
- GitOps Workflow
- Demo Scenarios
- Technology Stack
- Learning Path
- Troubleshooting
- Contributing
- Resources
This project implements a production-ready GitOps workflow using a simple TODO application to demonstrate:
- Cloud-native development with containerized microservices
- GitOps principles with ArgoCD for automated deployments
- Multi-environment management (development, staging)
- Security-first approach with sealed secrets and vulnerability scanning
- Observability with metrics, health checks, and monitoring
- Scalability with Horizontal Pod Autoscaler (HPA)
- Infrastructure as Code with Helm charts and Kubernetes manifests
β
GitOps Fundamentals - Declarative, Git-driven operations
β
Kubernetes Orchestration - Container deployment and management
β
CI/CD Automation - Automated testing, building, and deployment
β
Security Best Practices - Secret management and vulnerability scanning
β
Monitoring & Observability - Metrics collection and health monitoring
β
Infrastructure as Code - Reproducible infrastructure deployment
graph TB
subgraph "Developer Workflow"
DEV[π¨βπ» Developer] --> GIT[π¦ GitHub Repository]
GIT --> CI[π GitHub Actions]
CI --> REG[π Container Registry]
end
subgraph "GitOps Workflow"
GITOPS[π GitOps Repository] --> ARGO[π― ArgoCD]
ARGO --> K8S[βΈοΈ Kubernetes Cluster]
end
subgraph "Kubernetes Cluster (k3d)"
subgraph "Infrastructure"
TRAEFIK[π Traefik Ingress]
METRICS[π Metrics Server]
SEALED[π Sealed Secrets]
end
subgraph "Applications"
DEV_ENV[π§ Development Environment]
STG_ENV[π Staging Environment]
end
end
CI --> ARGO
REG --> K8S
TRAEFIK --> DEV_ENV
TRAEFIK --> STG_ENV
- Application Repository (
todo-app/): Node.js/Express REST API with Redis - GitOps Repository (
todo-gitops/): ArgoCD applications and Kubernetes manifests - Infrastructure: k3d cluster with Traefik, ArgoCD, and monitoring
- RESTful TODO API with full CRUD operations
- Redis persistence for data storage
- Health checks and Prometheus metrics
- Input validation and error handling
- Security hardening (non-root containers, read-only filesystem)
- ArgoCD app-of-apps pattern for multi-application management
- Automated deployments to development environment
- Manual approval workflow for staging deployments
- GitHub Actions CI/CD with testing and security scanning
- Dependency management with Renovate Bot
- Helm charts with environment-specific configurations
- Horizontal Pod Autoscaler (HPA) for automatic scaling
- Ingress routing with Traefik
- ConfigMaps and Secrets management
- Resource limits and security contexts
- Rolling deployments with zero downtime
- Sealed Secrets for encrypted secret management
- Vulnerability scanning with Trivy
- SBOM generation for supply chain security
- Container security best practices
- Network policies ready
- Prometheus metrics collection
- Health monitoring endpoints
- Resource usage tracking
- Application performance metrics
- Scaling events monitoring
| Component | Version | Purpose |
|---|---|---|
| Docker | 20.10+ | Container runtime |
| k3d | 5.4+ | Local Kubernetes cluster |
| kubectl | 1.25+ | Kubernetes CLI |
| Helm | 3.8+ | Package manager |
| Git | 2.30+ | Version control |
- β Linux (Ubuntu 20.04+, Debian 11+)
- β macOS (Intel & Apple Silicon)
- β Windows (WSL2 + Docker Desktop)
Choose your platform and run the appropriate setup:
Linux/macOS:
curl -fsSL https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bashWindows (PowerShell):
# Install using Chocolatey
choco install kubernetes-cli helm k3d
# Or use Scoop
scoop install kubectl helm k3d# Clone the repository
git clone <your-repo-url>
cd k8s-gitops-lab
# Navigate to GitOps directory
cd todo-gitops
# Run the bootstrap script
chmod +x bootstrap/setup.sh
./bootstrap/setup.shThe setup script will:
- β Create a local k3d Kubernetes cluster
- β Install ArgoCD, Traefik, and essential components
- β Configure GitOps applications
- β Set up local development environment
# Check cluster status
kubectl get nodes
# Check ArgoCD applications
kubectl get applications -n argocd
# Check all pods
kubectl get pods -A| Service | URL | Credentials |
|---|---|---|
| ArgoCD UI | https://localhost:30443 | admin / (from setup output) |
| TODO App (Dev) | http://todo-dev.local:8080 | None |
| Kubernetes API | https://localhost:6550 | kubectl context |
# Navigate to application directory
cd ../todo-app
# Build and push to local registry
docker build -t k3d-registry.localhost:5001/todo-app:latest .
docker push k3d-registry.localhost:5001/todo-app:latest
# ArgoCD will automatically detect and deploy!k8s-gitops-lab/
βββ π± todo-app/ # Application Repository
β βββ π³ Dockerfile # Multi-stage container build
β βββ π¦ package.json # Node.js dependencies
β βββ π― src/server.js # Express.js application
β βββ βοΈ .github/workflows/ # CI/CD pipelines
β βββ β΅ charts/todo/ # Helm chart
β βββ π values.yaml # Default configuration
β βββ π§ values-dev.yaml # Development settings
β βββ π values-stg.yaml # Staging settings
β βββ π templates/ # Kubernetes manifests
βββ π todo-gitops/ # GitOps Repository
β βββ π― app-of-apps.yaml # ArgoCD app-of-apps
β βββ π applications/ # ArgoCD app definitions
β βββ π environments/ # Environment configurations
β βββ π¨ bootstrap/ # Setup scripts
β βββ π docs/ # Architecture documentation
βββ π PROJECT_SUMMARY.md # Detailed project overview
βββ π README.md # This file
| Repository | Purpose | Key Components |
|---|---|---|
todo-app/ |
Application source code | Source code, Dockerfile, Helm charts, CI/CD |
todo-gitops/ |
GitOps configuration | ArgoCD apps, environment configs, secrets |
sequenceDiagram
participant Dev as π¨βπ» Developer
participant App as π± todo-app
participant CI as π GitHub Actions
participant Reg as π Registry
participant GitOps as π todo-gitops
participant ArgoCD as π― ArgoCD
participant K8s as βΈοΈ Kubernetes
Dev->>App: 1. Push code changes
App->>CI: 2. Trigger CI/CD pipeline
CI->>CI: 3. Run tests & security scans
CI->>Reg: 4. Build & push container image
CI->>GitOps: 5. Update image tag (optional)
GitOps->>ArgoCD: 6. Detect configuration changes
ArgoCD->>K8s: 7. Deploy to cluster
K8s-->>Dev: 8. Application updated
| Environment | Sync Policy | Purpose | Namespace |
|---|---|---|---|
| Development | Auto-sync | Continuous integration testing | todo-dev |
| Staging | Manual approval | Pre-production validation | todo-staging |
| Production | Manual approval | Live application | todo-prod |
# 1. Make code changes
cd todo-app/src
# Edit server.js
# 2. Build and push
docker build -t k3d-registry.localhost:5001/todo-app:v1.1.0 .
docker push k3d-registry.localhost:5001/todo-app:v1.1.0
# 3. Watch ArgoCD auto-deploy
kubectl get pods -n todo-dev -w# Run the interactive autoscaling demonstration
cd todo-gitops/bootstrap
chmod +x demo.sh
./demo.sh
# Watch HPA in action
kubectl get hpa -n todo-dev -w# Create a sealed secret
echo -n 'super-secret-password' | kubeseal --raw \
--from-file=/dev/stdin \
--name my-secret \
--namespace todo-dev
# Deploy via GitOps
git add . && git commit -m "Add new secret" && git push# Tag stable version
git tag v1.2.0
git push origin v1.2.0
# Update staging environment via ArgoCD UI
# Manual sync staging application| Technology | Purpose | Version |
|---|---|---|
| Node.js | Runtime environment | 18+ |
| Express.js | Web framework | ^4.18 |
| Redis | Data persistence | Alpine |
| Joi | Input validation | ^17.11 |
| Technology | Purpose | Version |
|---|---|---|
| Kubernetes | Container orchestration | 1.25+ |
| k3d | Local K8s clusters | 5.4+ |
| ArgoCD | GitOps operator | 2.8+ |
| Traefik | Ingress controller | Latest |
| Helm | Package manager | 3.8+ |
| Tool | Purpose | Integration |
|---|---|---|
| GitHub Actions | CI/CD automation | Automated testing, building |
| Trivy | Vulnerability scanning | Security pipeline |
| Renovate | Dependency management | Automated updates |
| Sealed Secrets | Secret encryption | Secure GitOps |
- Setup Environment - Run quick start guide
- Explore Application - Understand TODO API
- GitOps Basics - Learn ArgoCD interface
- Deploy Changes - Make simple code modifications
- Helm Customization - Modify chart values
- Multi-Environment - Deploy to staging
- Secret Management - Create sealed secrets
- Monitoring Setup - Configure metrics
- Security Hardening - Implement policies
- Custom Operators - Extend functionality
- Production Setup - Real cluster deployment
- Disaster Recovery - Backup strategies
# Check Docker status
docker info
# Clean up existing clusters
k3d cluster delete todo-local
# Retry with verbose logging
k3d cluster create todo-local --verbose# Check ArgoCD pods
kubectl get pods -n argocd
# Port forward as backup
kubectl port-forward svc/argocd-server -n argocd 8080:80# Force refresh application
argocd app get todo-dev --refresh
# Check application logs
kubectl logs -f deployment/todo -n todo-dev# Verify registry is running
docker ps | grep registry
# Test registry connectivity
curl -k http://k3d-registry.localhost:5001/v2/_catalog- Check Logs:
kubectl logs -f deployment/todo -n todo-dev - Describe Resources:
kubectl describe pod <pod-name> -n todo-dev - ArgoCD Status:
argocd app get todo-dev - Health Checks:
curl http://todo-dev.local:8080/healthz
For detailed troubleshooting, see: todo-gitops/docs/TROUBLESHOOTING.md
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Test locally using the setup scripts
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- π Documentation improvements
- π Bug fixes and issue resolution
- β¨ New feature development
- π§ Infrastructure enhancements
- π§ͺ Additional demo scenarios
- π Security improvements
- β Follow existing code style
- β Add appropriate tests
- β Update documentation
- β Ensure security best practices
- π Kubernetes Documentation
- π ArgoCD Documentation
- π Helm Documentation
- π k3d Documentation
- π GitOps Principles
- πΊ CNCF YouTube Channel
- π Kubernetes Learning Path
- π Certified Kubernetes Administrator (CKA)
- π¬ Kubernetes Slack
- π¦ CNCF Twitter
- π GitOps Working Group
This project is licensed under the MIT License - see the LICENSE file for details.
- Cloud Native Computing Foundation (CNCF) for the amazing ecosystem
- ArgoCD Team for the excellent GitOps platform
- Kubernetes Community for the robust orchestration platform
- All Contributors who helped improve this project