{{- if .Values.gotenberg.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "docuelevate.fullname" . }}-gotenberg
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "docuelevate.labels" . | nindent 4 }}
    app.kubernetes.io/component: gotenberg
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "docuelevate.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: gotenberg
  template:
    metadata:
      labels:
        {{- include "docuelevate.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: gotenberg
    spec:
      containers:
        - name: gotenberg
          image: {{ .Values.gotenberg.image.repository }}:{{ .Values.gotenberg.image.tag }}
          imagePullPolicy: {{ .Values.gotenberg.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          resources:
            {{- toYaml .Values.gotenberg.resources | nindent 12 }}
          livenessProbe:
            httpGet:
              path: /health
              port: 3000
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /health
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "docuelevate.fullname" . }}-gotenberg
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "docuelevate.labels" . | nindent 4 }}
    app.kubernetes.io/component: gotenberg
spec:
  type: ClusterIP
  ports:
    - port: {{ .Values.gotenberg.service.port }}
      targetPort: http
      protocol: TCP
      name: http
  selector:
    {{- include "docuelevate.selectorLabels" . | nindent 4 }}
    app.kubernetes.io/component: gotenberg
{{- end }}
