{{- if .Values.pushgateway.enabled -}}
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  labels:
    app: {{ template "prometheus.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    component: "{{ .Values.pushgateway.name }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "prometheus.pushgateway.fullname" . }}
spec:
  replicas: {{ .Values.pushgateway.replicaCount }}
  template:
    metadata:
    {{- if .Values.pushgateway.podAnnotations }}
      annotations:
{{ toYaml .Values.pushgateway.podAnnotations | indent 8 }}
    {{- end }}
      labels:
        app: {{ template "prometheus.name" . }}
        component: "{{ .Values.pushgateway.name }}"
        release: {{ .Release.Name }}
    spec:
      serviceAccountName: {{ template "prometheus.serviceAccountName.pushgateway" . }}
      containers:
        - name: {{ template "prometheus.name" . }}-{{ .Values.pushgateway.name }}
          image: "{{ .Values.pushgateway.image.repository }}:{{ .Values.pushgateway.image.tag }}"
          imagePullPolicy: "{{ .Values.pushgateway.image.pullPolicy }}"
          args:
          {{- range $key, $value := .Values.pushgateway.extraArgs }}
            - --{{ $key }}={{ $value }}
          {{- end }}
          ports:
            - containerPort: 9091
          readinessProbe:
            httpGet:
              path: /#/status
              port: 9091
            initialDelaySeconds: 10
            timeoutSeconds: 10
          resources:
{{ toYaml .Values.pushgateway.resources | indent 12 }}
    {{- if .Values.pushgateway.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.pushgateway.nodeSelector | indent 8 }}
    {{- end }}
    {{- if .Values.pushgateway.tolerations }}
      tolerations:
{{ toYaml .Values.pushgateway.tolerations | indent 8 }}
    {{- end }}
    {{- if .Values.pushgateway.affinity }}
      affinity:
{{ toYaml .Values.pushgateway.affinity | indent 8 }}
    {{- end }}
{{- end }}
