{{- if .Values.manager.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "eddi.fullname" . }}-manager
  labels:
    {{- include "eddi.labels" . | nindent 4 }}
    app.kubernetes.io/component: ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "eddi.fullname" . }}-manager
      app.kubernetes.io/component: ui
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "eddi.fullname" . }}-manager
        app.kubernetes.io/component: ui
        app.kubernetes.io/part-of: eddi
    spec:
      containers:
        - name: manager
          image: "{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }}"
          ports:
            - containerPort: 7071
              name: http
          env:
            - name: EDDI_API_URL
              value: "http://{{ include "eddi.fullname" . }}:7070"
            - name: PORT
              value: "7071"
          resources:
            {{- toYaml .Values.manager.resources | nindent 12 }}
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 10
            periodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "eddi.fullname" . }}-manager
  labels:
    {{- include "eddi.labels" . | nindent 4 }}
    app.kubernetes.io/component: ui
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: {{ include "eddi.fullname" . }}-manager
    app.kubernetes.io/component: ui
  ports:
    - name: http
      port: 7071
      targetPort: http
{{- end }}
