{{ if .Values.ai.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ai
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ai
  template:
    metadata:
      name: ai
      labels:
        app: ai
    spec:
      containers:
      - name: ai
        image: goalprofit/ai:{{.Values.ai.version}}
        imagePullPolicy: Always
        env:
        - name: OPENAI_API_KEY
          valueFrom:
            secretKeyRef:
              name: secret-openai
              key: key
              optional: false
        - name: SERVICE_LOGIN
          valueFrom:
            secretKeyRef:
              name: secret-service
              key: username
              optional: false
        - name: SERVICE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: secret-service
              key: password
              optional: false
      imagePullSecrets:
      - name: regcred
      {{ include "app.affinity" . | nindent 6}}

---
apiVersion: v1
kind: Service
metadata:
  name: ai
spec:
  type: ClusterIP
  selector:
    app: ai
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080

{{ end }}