---
apiVersion: v1
kind: Service
metadata:
  name: ai-backend
spec:
  selector:
    app: ai-backend
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
  type: ClusterIP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ai-backend
spec:
  serviceName: ai-backend
  replicas: 1
  selector:
    matchLabels:
      app: ai-backend
  template:
    metadata:
      labels:
        app: ai-backend
    spec:
      containers:
      - name: ai-backend
        image: dexorder/ai-backend
        ports:
        - containerPort: 8000
        env:
        - name: CONFIG
          value: "dev"
        - name: ANTHROPIC_API_KEY
          valueFrom:
            secretKeyRef:
              name: ai-secrets
              key: anthropic-api-key
        volumeMounts:
        - name: ai-backend-data
          mountPath: /app/data
  volumeClaimTemplates:
    - metadata:
        name: ai-backend-data
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi
