{{ if .Values.assistant.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: assistant
spec:
  replicas: 1
  selector:
    matchLabels:
      app: assistant
  template:
    metadata:
      name: assistant
      labels:
        app: assistant
    spec:
      containers:
      - name: assistant
        image: goalprofit/assistant:{{.Values.assistant.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: assistant
spec:
  type: ClusterIP
  selector:
    app: assistant
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080

{{ end }}