ai-code-battle/deploy/k8s/deployments/acb-api.yaml
jedarden f1a0830c51 Add Go API server (cmd/acb-api) with PostgreSQL, Valkey, and Glicko-2
Implements the K8s-native Go API service per the plan architecture:
- HTTP server with graceful shutdown and env-var configuration
- PostgreSQL schema (bots, matches, match_participants, jobs, rating_history)
- Health/ready endpoints checking PostgreSQL and Valkey connectivity
- Bot registration with health check, HMAC secret gen, AES-256-GCM encryption
- Key rotation and bot status endpoints
- Job claim via Valkey BRPOP, result submission with Glicko-2 rating update
- Glicko-2 rating system: multi-player pairwise, Illinois volatility algorithm
- Background tickers: matchmaker (1m), health checker (15m), stale job reaper (5m)
- Worker API key authentication (Bearer/X-API-Key)
- Dockerfile, K8s Deployment (2 replicas), ClusterIP Service
- 30 unit tests covering Glicko-2, crypto, config, and handlers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 01:21:48 -04:00

72 lines
2 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: acb-api
namespace: ai-code-battle
labels:
app.kubernetes.io/name: acb-api
app.kubernetes.io/part-of: ai-code-battle
app.kubernetes.io/component: api
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: acb-api
template:
metadata:
labels:
app.kubernetes.io/name: acb-api
app.kubernetes.io/part-of: ai-code-battle
app.kubernetes.io/component: api
spec:
containers:
- name: api
image: forgejo.ardenone.com/ai-code-battle/acb-api:latest
env:
- name: ACB_LISTEN_ADDR
value: ":8080"
- name: ACB_DATABASE_URL
valueFrom:
secretKeyRef:
name: acb-postgres-credentials
key: database-url
- name: ACB_VALKEY_ADDR
value: "valkey-master.valkey.svc.cluster.local:6379"
- name: ACB_VALKEY_PASSWORD
valueFrom:
secretKeyRef:
name: acb-valkey-credentials
key: password
- name: ACB_WORKER_API_KEY
valueFrom:
secretKeyRef:
name: acb-api-key
key: api-key
- name: ACB_ENCRYPTION_KEY
valueFrom:
secretKeyRef:
name: acb-encryption-key
key: key
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 5
periodSeconds: 30
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 256Mi
restartPolicy: Always