Allt i Kubernetes: containrar, manifest, orkestertjänst och CI
Målarkitekturen ur Master Prompt som kod: - Webben containeriserad (flerstegs-Dockerfile → oprivilegierad nginx med SPA-fallback, hashade assets cachas hårt, säkerhetsheaders). - AI-orkestern som egen tjänst (services/ai-orkester): samma routing och AI-regler som edge-funktionen men körbar som pod — egen HS256-JWT-verifiering (fail closed), /halsa, storleksgränser, read-only container som kör som node-användaren. Livetestad: hälsokontroll ok, 401 utan/med ogiltig token, 400-validering bakom giltig JWT. - Kubernetes-manifest (infra/k8s, kustomize): namespace, Deployments med readiness/liveness och åtstramad securityContext, Services, HPA 2–10 pods på 70 % CPU, PodDisruptionBudgets, Ingress med TLS via cert-manager, secret-mall (riktiga värden skapas utanför git). - Klienten väljer AI-väg vid bygget: VITE_AI_ORKESTER_URL → tjänsten i klustret, annars Supabase-edge-funktionen. Samma orkester i båda, låst av paritetstest. - CI-arbetsflöde: tester + produktionsbygge + verifierande containerbyggen av båda bilderna på varje push/PR. - docs/DRIFT.md: arkitekturdiagram, driftsättningssteg, skalning, och vad som återstår mot full självhostning. Verifierat: 27 vitest-tester gröna, produktionsbygge ok, alla K8s-manifest YAML-validerade, orkestertjänsten livetestad, Playwright-röktest grönt. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012EQg3rJsrQ1ZNTvkzmQAtt
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# Webbklienten: statisk SPA bakom oprivilegierad nginx.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: web
|
||||
namespace: guidad-felsokning
|
||||
labels: { app: web }
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels: { app: web }
|
||||
template:
|
||||
metadata:
|
||||
labels: { app: web }
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
containers:
|
||||
- name: web
|
||||
image: ghcr.io/ORGANISATION/guidad-felsokning-web:latest # ersätt med ert registry
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
resources:
|
||||
requests: { cpu: 50m, memory: 64Mi }
|
||||
limits: { cpu: 250m, memory: 128Mi }
|
||||
readinessProbe:
|
||||
httpGet: { path: /, port: 8080 }
|
||||
initialDelaySeconds: 3
|
||||
livenessProbe:
|
||||
httpGet: { path: /, port: 8080 }
|
||||
periodSeconds: 15
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: { drop: [ALL] }
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
namespace: guidad-felsokning
|
||||
spec:
|
||||
selector: { app: web }
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
---
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: web
|
||||
namespace: guidad-felsokning
|
||||
spec:
|
||||
scaleTargetRef: { apiVersion: apps/v1, kind: Deployment, name: web }
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target: { type: Utilization, averageUtilization: 70 }
|
||||
---
|
||||
apiVersion: policy/v1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: web
|
||||
namespace: guidad-felsokning
|
||||
spec:
|
||||
minAvailable: 1
|
||||
selector:
|
||||
matchLabels: { app: web }
|
||||
Reference in New Issue
Block a user