apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "helm-exporter.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "helm-exporter.name" . }}
    helm.sh/chart: {{ include "helm-exporter.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.annotations }}
      annotations:
{{ toYaml . | indent 8 }}
{{- end }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "helm-exporter.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "helm-exporter.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.podAnnotations }}
      annotations:
{{ toYaml . | indent 8 }}
{{- end }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          {{- if .Values.tillerNamespaces }}
          args: ["-tiller-namespaces", {{ .Values.tillerNamespaces | quote }}]
          {{- end }}
          ports:
            - name: http
              containerPort: 9571
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: http
          readinessProbe:
            httpGet:
              path: /healthz
              port: http
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- if .Values.rbac.create }}
      serviceAccountName: {{ template "helm-exporter.fullname" . }}
    {{- else }}
      serviceAccountName: "{{ .Values.rbac.serviceAccountName }}"
    {{- end }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- if .Values.image.pullSecrets }}
      imagePullSecrets:
      {{- range .Values.image.pullSecrets }}
        - name: {{ . }}
      {{- end }}
    {{- end }}
