{{ if .Values.logsearchapi.enabled }}
{{ $values := (. | mustDeepCopy) }}
{{ $_ := set $values "common" (dict "nameSuffix" (include "logsearchapi.nameSuffix" .)) }}
{{ $pg_values := (. | mustDeepCopy) }}
{{ $_ := set $pg_values "common" (dict "nameSuffix" (include "postgres.nameSuffix" .)) }}
{{ include "common.deployment.common_config" $values | nindent 0 }}
spec: {{ include "common.deployment.common_spec" $values | nindent 2 }}
  template: {{ include "common.deployment.pod.metadata" $values | nindent 4 }}
    spec:
      initContainers:
        - name: {{ .Chart.Name }}-{{ include "logsearchapi.nameSuffix" . }}-waitdb
          image: {{ include "postgres.imageName" . }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env: {{ include "postgresInit.envVariableConfiguration" $pg_values | nindent 10 }}
          command:
            - sh
            - -c
            - 'until pg_isready -U "$pgUser" -h "$pgHost"; do sleep 2; done'
      containers:
        - name: {{ .Chart.Name }}-{{ include "logsearchapi.nameSuffix" . }}
          image: {{ include "logsearchapi.imageName" . }}
          imagePullPolicy: {{ .Values.logSearchImage.pullPolicy }}
          env: {{ include "logsearchapi.envVariableConfiguration" $values | nindent 10 }}
          command:
            - {{ include "logsearchapi.command" . }}
          ports:
            - name: logsearchapi
              containerPort: 8080
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /status
              port: 8080
            failureThreshold: 5
            periodSeconds: 15
            initialDelaySeconds: 15
          livenessProbe:
            httpGet:
              path: /status
              port: 8080
            failureThreshold: 5
            periodSeconds: 15
            initialDelaySeconds: 15
          startupProbe:
            httpGet:
              path: /status
              port: 8080
            failureThreshold: 5
            periodSeconds: 15
            initialDelaySeconds: 15
{{ end }}
