{{ if .Values.camunda.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: camunda
spec:
  replicas: 1
  selector:
    matchLabels:
      app: camunda
  template:
    metadata:
      name: camunda
      labels:
        app: camunda
    spec:
      containers:
      - name: camunda
        image: camunda/camunda-bpm-platform:7.16.0
        ports:
          - containerPort: 8080
        env:
          - name: LOG4J_FORMAT_MSG_NO_LOOKUPS
            value: "true"

        volumeMounts:
        - mountPath: /camunda/camunda-h2-dbs
          name: camunda

      volumes:
      - name: camunda
        hostPath:
          path: /data/{{.Values.customer}}/camunda/camunda-h2-dbs
          type: Directory
---
apiVersion: v1
kind: Service
metadata:
  name: camunda
spec:
  type: ClusterIP
  selector:
    app: camunda
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: camunda-mailer
spec:
  selector:
    matchLabels:
      app: camunda-mailer
  template:
    metadata:
      labels:
        app: camunda-mailer
    spec:
      containers:
        - name: camunda-mailer
          image: goalprofit/camunda-mailer:latest
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /app/.auth
              name: auth
          command:
            - python3
            - main.py
            {{ range .Values.camunda.mailer.args }}
            - {{ . }}
            {{ end }}
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always
      volumes:
        - name: auth
          hostPath:
            path: {{.Values.camunda.mailer.auth}}
            type: File
      {{ include "app.affinity" . | nindent 6}}

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: camunda-graphql
spec:
  selector:
    matchLabels:
      app: camunda-graphql
  template:
    metadata:
      labels:
        app: camunda-graphql
    spec:
      containers:
        - name: camunda-graphql
          image: goalprofit/camunda-server-query:latest
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /app/.auth
              name: auth
          command:
            - python3
            - main.py
            {{ range .Values.camunda.graphql.args }}
            - {{ . }}
            {{ end }}
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always
      volumes:
        - name: auth
          hostPath:
            path: {{ .Values.camunda.graphql.auth }}
            type: File
{{ end }}
