apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: {{ template "prometheus-to-sd.fullname" . }}
  labels:
    app: {{ template "prometheus-to-sd.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    metadata:
      labels:
        app: {{ template "prometheus-to-sd.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: profiler
              containerPort: {{ .Values.port }}
          command:
            - /monitor
            - --stackdriver-prefix=custom.googleapis.com
            {{- range $key, $value := .Values.metricsSources }}
            - --source={{ $key }}:{{ $value }}
            {{- end }}
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
