apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "prometheus-redis-exporter.fullname" . }}
  labels:
    app: {{ template "prometheus-redis-exporter.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "prometheus-redis-exporter.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      annotations:
{{ toYaml .Values.annotations | indent 8 }}
      labels:
        app: {{ template "prometheus-redis-exporter.name" . }}
        release: {{ .Release.Name }}
    spec:
      serviceAccountName: {{ template "prometheus-redis-exporter.serviceAccountName" . }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          args:
          {{- range $key, $value := .Values.extraArgs }}
            - --{{ $key }}={{ $value }}
          {{- end }}
          ports:
            - name: exporter-port
              containerPort: 9121
          env:
            - name: REDIS_ADDR
              value: {{ .Values.redisAddress }}
          livenessProbe:
            httpGet:
              path: /
              port: exporter-port
          readinessProbe:
            httpGet:
              path: /
              port: exporter-port
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
