apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "seq.fullname" . }}
  labels:
    app: {{ template "seq.name" . }}
    chart: {{ template "seq.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  selector:
    matchLabels:
      app: {{ template "seq.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "seq.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: "ACCEPT_EULA"
              value: "{{ .Values.acceptEULA }}"
          ports:
            - name: ingestion
              containerPort: 5341
              protocol: TCP
            - name: ui
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: ui
          readinessProbe:
            httpGet:
              path: /
              port: ui
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- with .Values.nodeSelector }}
          volumeMounts:
            - name: seq-data
              mountPath: {{ .Values.persistence.path }}
              subPath: {{ .Values.persistence.subPath }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
    volumes:
      - name: seq-data
      {{- if .Values.persistence.enabled }}
        persistentVolumeClaim:
          claimName: {{ .Values.persistence.existingClaim | default (include "seq.fullname" .) }}
      {{- else }}
        emptyDir: {}
      {{- end -}}
