apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.name }}-deployment
  labels:
    app: {{ .Values.name }}
    version: {{ .Values.version }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Values.name }}
      version: {{ .Values.version }}
  strategy:
    type: RollingUpdate
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
        traffic.sidecar.istio.io/excludeOutboundPorts: '5432'
      labels:
        app: {{ .Values.name }}
        version: {{ .Values.version }}
        collect.logs: "plain-text"
    spec:
      serviceAccountName: {{ .Values.name }}
      containers:
        - name: {{ .Values.name }}
          image: "{{ .Values.image.name }}:{{ .Values.image.version }}"
          imagePullPolicy: Always
          ports:
            - containerPort: {{ .Values.port }}
              protocol: TCP
          livenessProbe:
            httpGet:
              path: {{ .Values.probes.liveness.path }}
              port: {{ .Values.port }}
              httpHeaders:
                - name: X-B3-Sampled
                  value: "0"
            failureThreshold: 1
            initialDelaySeconds: 180
            periodSeconds: 20
            successThreshold: 1
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: {{ .Values.probes.readiness.path }}
              port: {{ .Values.port }}
              httpHeaders:
                - name: X-B3-Sampled
                  value: "0"
            failureThreshold: 5
            initialDelaySeconds: 60
            periodSeconds: 20
            successThreshold: 1
            timeoutSeconds: 5
          resources:
            requests:
              memory: 500Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /app/config/config.yaml
              name: config
              readOnly: true
              subPath: config.yaml
          env:
            - name: OPENSHIFT_NAMESPACE
              value: {{ .Values.namespace }}
            - name: REDASH_URL
              value: http://admin-tools-redash-admin:5000/reports
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - name: config
          configMap:
            name: report-exporter-properties
