apiVersion: apps/v1
kind: Deployment
metadata:
  name: stt-server
  namespace: ai
spec:
  replicas: 1
  selector:
    matchLabels:
      app: stt-server
  template:
    metadata:
      labels:
        app: stt-server
    spec:
      # Image privée sur ghcr → secret de pull créé manuellement dans le ns ai
      # (cf. README : kubectl create secret docker-registry ghcr-pull ...)
      imagePullSecrets:
        - name: ghcr-pull
      # Conformité PodSecurity "restricted" (namespace ai)
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: stt-server
          # Tag géré par la CI (build-stt-server.yml) : bumpé en sha-<commit> à chaque build main.
          image: ghcr.io/alkatrazz24/funk-stt-server:sha-d982308
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
          ports:
            - containerPort: 8000
          env:
            # LiteLLM (s01) joint en IP directe — même pattern qu'open-webui
            - name: STT_LITELLM_URL
              value: "http://192.168.10.1:4000/v1/chat/completions"
            - name: STT_LITELLM_KEY
              value: "lm-studio"
            - name: STT_MODEL
              value: "hermes-default"
            # Mémoire long-terme (Qdrant s01 + embeddings nomic gpu-01) — dégrade si injoignable
            - name: STT_MEMORY_LONGTERM
              value: "true"
            - name: STT_QDRANT_URL
              value: "http://192.168.10.1:6333"
            # Instance dédiée embeddings nomic-embed-text sur gpu-01 (:1238, dim 768)
            - name: STT_EMBED_URL
              value: "http://192.168.10.20:1238/v1/embeddings"
            - name: STT_EMBED_MODEL
              value: "nomic-embed-text"
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8000
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8000
            initialDelaySeconds: 10
            periodSeconds: 20
          resources:
            requests:
              cpu: 50m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 256Mi
