{{- if include "test.host" . -}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "test.fullname" . }}
  labels:
    app: {{ template "test.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  selector:
    matchLabels:
      app: {{ template "test.fullname" . }}
      release: "{{ .Release.Name }}"
  replicas: 1
  template:
    metadata:
      labels:
        app: {{ template "test.fullname" . }}
        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
        release: "{{ .Release.Name }}"
    spec:
      {{- if .Values.image.pullSecrets }}
      imagePullSecrets:
      {{- range .Values.image.pullSecrets }}
        - name: {{ . }}
      {{- end}}
      {{- end }}
      containers:
      - name: {{ template "test.fullname" . }}
        image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
        ports:
        - name: http
          containerPort: 3000
        livenessProbe:
          httpGet:
            path: {{ .Values.testPath }}
            port: http
            httpHeaders:
            - name: Host
              value: {{ include "test.host" . | quote }}
          initialDelaySeconds: 120
          timeoutSeconds: 5
          failureThreshold: 6
        readinessProbe:
          httpGet:
            path: {{ .Values.testPath }}
            port: http
            httpHeaders:
            - name: Host
              value: {{ include "test.host" . | quote }}
          initialDelaySeconds: 30
          timeoutSeconds: 3
          periodSeconds: 5
        resources:
{{ toYaml .Values.resources | indent 10 }}
{{- end -}}
