section: Docker & Kubernetes | prio: P1 | est: 4h | deps: BE-INFRA-01, BE-INFRA-02
Pourquoi
Le scaling horizontal automatique (HPA) permet dabsorber les pics de charge sans intervention manuelle. Distroless réduit la surface dattaque et la taille dimage.
Acceptance Criteria
- Dockerfile multi-stage :
FROM golang:1.22 AS builder → go build -ldflags="-w -s" → FROM gcr.io/distroless/static-debian12 — image finale < 20MB, pas de shell, pas de package manager
- docker-compose.yml dev : api (hot-reload via
air), postgres:15-alpine (volume + migrations auto), redis:7-alpine (single node AOF), pgbouncer
- K8s Deployment :
replicas: 3 minimum, resources: {requests: {cpu: 250m, memory: 256Mi}, limits: {cpu: 1000m, memory: 512Mi}}, rolling update maxSurge: 1, maxUnavailable: 0 (zero-downtime)
- HPA : scale out si CPU > 70% OU
bcrypt_pool_queue_length > 100 (custom metric via Prometheus Adapter), min=3 replicas, max=50 replicas — permet dabsorber 2M users actifs simultanés
- PodDisruptionBudget :
minAvailable: 2 — jamais moins de 2 pods pendant les maintenances
- Liveness probe :
GET /api/v1/health timeout 5s period 10s. Readiness probe : GET /api/v1/ready (vérifie PG + Redis) timeout 3s period 5s
- ConfigMap : config non-sensible. Secret : tous les credentials via K8s Secrets ou Vault
- Makefile :
make up, make down, make migrate-up, make migrate-down, make test-unit, make test-integration, make build
Fichiers
Dockerfile
docker-compose.yml
k8s/
├── deployment.yaml
├── hpa.yaml
├── pdb.yaml
├── service.yaml
└── configmap.yaml
Makefile
Scale
HPA auto-scale jusqu'à 50 pods = 50 × 150k req/s = 7.5M req/s théorique. En pratique, limité par pgBouncer et Redis.
section: Docker & Kubernetes | prio: P1 | est: 4h | deps: BE-INFRA-01, BE-INFRA-02
Pourquoi
Le scaling horizontal automatique (HPA) permet dabsorber les pics de charge sans intervention manuelle. Distroless réduit la surface dattaque et la taille dimage.
Acceptance Criteria
FROM golang:1.22 AS builder→go build -ldflags="-w -s"→FROM gcr.io/distroless/static-debian12— image finale < 20MB, pas de shell, pas de package managerair), postgres:15-alpine (volume + migrations auto), redis:7-alpine (single node AOF), pgbouncerreplicas: 3minimum,resources: {requests: {cpu: 250m, memory: 256Mi}, limits: {cpu: 1000m, memory: 512Mi}}, rolling updatemaxSurge: 1,maxUnavailable: 0(zero-downtime)bcrypt_pool_queue_length > 100(custom metric via Prometheus Adapter), min=3 replicas, max=50 replicas — permet dabsorber 2M users actifs simultanésminAvailable: 2— jamais moins de 2 pods pendant les maintenancesGET /api/v1/healthtimeout 5s period 10s. Readiness probe :GET /api/v1/ready(vérifie PG + Redis) timeout 3s period 5smake up,make down,make migrate-up,make migrate-down,make test-unit,make test-integration,make buildFichiers
Scale
HPA auto-scale jusqu'à 50 pods = 50 × 150k req/s = 7.5M req/s théorique. En pratique, limité par pgBouncer et Redis.