|
| 1 | +# Phase 4: Local Kubernetes Deployment |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Phase 4 packages the DoIt platform for local Kubernetes deployment using Minikube. All three services (frontend, backend, MCP) are containerized with optimized multi-stage Docker builds and orchestrated through an umbrella Helm chart with subcharts. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +``` |
| 10 | +Browser → Ingress (doit.local) |
| 11 | + ├── / → Frontend Service (ClusterIP :3000) |
| 12 | + ├── /api → Backend Service (ClusterIP :8000) |
| 13 | + └── /mcp → MCP Service (ClusterIP :8080) |
| 14 | +
|
| 15 | +Internal (server-side): |
| 16 | + Frontend Pod ──BACKEND_URL──→ Backend Service (doit-backend:8000) |
| 17 | + Frontend Pod ──MCP_URL──────→ MCP Service (doit-mcp:8080) |
| 18 | +
|
| 19 | +External: |
| 20 | + All Pods ──DATABASE_URL──→ Neon PostgreSQL (internet) |
| 21 | +``` |
| 22 | + |
| 23 | +## Components |
| 24 | + |
| 25 | +### Docker Images |
| 26 | + |
| 27 | +| Service | Base Image | Stages | Port | Size | |
| 28 | +|---------|-----------|--------|------|------| |
| 29 | +| Backend | python:3.13-slim | 2 (builder + runtime) | 8000 | ~200-300MB | |
| 30 | +| MCP | python:3.13-slim | 2 (builder + runtime) | 8080 | ~200-300MB | |
| 31 | +| Frontend | node:20-alpine | 3 (deps + builder + runtime) | 3000 | ~100-200MB | |
| 32 | + |
| 33 | +### Helm Chart Structure |
| 34 | + |
| 35 | +``` |
| 36 | +helm/doit/ # Umbrella chart |
| 37 | +├── Chart.yaml # Dependencies on subcharts |
| 38 | +├── values.yaml # Default configuration |
| 39 | +├── values.secret.yaml.example # Secret template |
| 40 | +├── .helmignore |
| 41 | +├── templates/ |
| 42 | +│ ├── ingress.yaml # Path-based routing |
| 43 | +│ └── _helpers.tpl # Common helpers |
| 44 | +└── charts/ |
| 45 | + ├── frontend/ # Frontend subchart |
| 46 | + │ └── templates/ # Deployment, Service, ConfigMap, Secret |
| 47 | + ├── backend/ # Backend subchart |
| 48 | + │ └── templates/ # Deployment, Service, ConfigMap, Secret |
| 49 | + └── mcp/ # MCP subchart |
| 50 | + └── templates/ # Deployment, Service, ConfigMap, Secret |
| 51 | +``` |
| 52 | + |
| 53 | +### Kubernetes Resources (per deployment) |
| 54 | + |
| 55 | +- 3 Deployments (one per service) |
| 56 | +- 3 Services (ClusterIP) |
| 57 | +- 3 ConfigMaps (non-sensitive env vars) |
| 58 | +- 3 Secrets (credentials, API keys) |
| 59 | +- 1 Ingress (shared, path-based routing) |
| 60 | + |
| 61 | +## Health Checks |
| 62 | + |
| 63 | +| Service | Path | Liveness | Readiness | |
| 64 | +|---------|------|----------|-----------| |
| 65 | +| Backend | `/health` | 30s interval | 10s interval | |
| 66 | +| MCP | `/health` | 30s interval | 10s interval | |
| 67 | +| Frontend | `/` | 30s interval | 10s interval | |
| 68 | + |
| 69 | +## Configuration |
| 70 | + |
| 71 | +### Environment Variables (ConfigMaps) |
| 72 | + |
| 73 | +| Service | Variable | Value | |
| 74 | +|---------|----------|-------| |
| 75 | +| Backend | `CORS_ORIGINS` | `http://doit.local` | |
| 76 | +| MCP | `MCP_HOST` | `0.0.0.0` | |
| 77 | +| MCP | `MCP_PORT` | `8080` | |
| 78 | +| Frontend | `BETTER_AUTH_URL` | `http://doit.local` | |
| 79 | +| Frontend | `NEXT_PUBLIC_BETTER_AUTH_URL` | `http://doit.local` | |
| 80 | +| Frontend | `NEXT_PUBLIC_API_URL` | `http://doit.local/api` | |
| 81 | +| Frontend | `BACKEND_URL` | `http://doit-backend:8000` | |
| 82 | +| Frontend | `MCP_URL` | `http://doit-mcp:8080` | |
| 83 | + |
| 84 | +### Secrets (values.secret.yaml) |
| 85 | + |
| 86 | +| Key | Required | Used By | |
| 87 | +|-----|----------|---------| |
| 88 | +| `global.databaseUrl` | Yes | All services | |
| 89 | +| `global.betterAuthSecret` | Yes | Backend, Frontend | |
| 90 | +| `global.geminiApiKey` | Yes | MCP | |
| 91 | +| `global.googleClientId` | No | Frontend | |
| 92 | +| `global.googleClientSecret` | No | Frontend | |
| 93 | +| `global.githubClientId` | No | Frontend | |
| 94 | +| `global.githubClientSecret` | No | Frontend | |
| 95 | + |
| 96 | +## Quickstart |
| 97 | + |
| 98 | +See [quickstart.md](../../specs/004-minikube-k8s-deployment/quickstart.md) for the full deployment guide. |
| 99 | + |
| 100 | +```bash |
| 101 | +# 1. Start Minikube |
| 102 | +minikube start --cpus=4 --memory=8192 --driver=docker |
| 103 | +minikube addons enable ingress |
| 104 | + |
| 105 | +# 2. Build images |
| 106 | +eval $(minikube docker-env) |
| 107 | +docker build -t doit-backend:latest ./backend |
| 108 | +docker build -t doit-mcp:latest ./mcp |
| 109 | +docker build -t doit-frontend:latest ./frontend |
| 110 | + |
| 111 | +# 3. Configure secrets |
| 112 | +cp helm/doit/values.secret.yaml.example helm/doit/values.secret.yaml |
| 113 | +# Edit with real values |
| 114 | + |
| 115 | +# 4. Deploy |
| 116 | +helm dependency update ./helm/doit |
| 117 | +helm install doit ./helm/doit -f ./helm/doit/values.secret.yaml |
| 118 | + |
| 119 | +# 5. DNS |
| 120 | +echo "$(minikube ip) doit.local" | sudo tee -a /etc/hosts |
| 121 | + |
| 122 | +# 6. Access |
| 123 | +open http://doit.local |
| 124 | +``` |
| 125 | + |
| 126 | +## Prerequisites |
| 127 | + |
| 128 | +- Docker Desktop 4.x+ |
| 129 | +- Minikube (4 CPUs / 8GB RAM minimum) |
| 130 | +- Helm 3 |
| 131 | +- kubectl |
| 132 | +- 16GB+ total RAM on host machine |
| 133 | + |
| 134 | +## Technologies |
| 135 | + |
| 136 | +| Technology | Purpose | |
| 137 | +|------------|---------| |
| 138 | +| Docker | Multi-stage container builds | |
| 139 | +| Minikube | Local Kubernetes cluster | |
| 140 | +| Helm 3 | Package management and templating | |
| 141 | +| nginx Ingress | Path-based HTTP routing | |
| 142 | +| Kubernetes | Container orchestration | |
0 commit comments