# _helpers.tpl
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-to-sd.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "prometheus-to-sd.fullname" -}}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
 # deployment.yaml
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 }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}

replicaCount: 1
image:
  repository: gcr.io/google-containers/prometheus-to-sd
  tag: v0.5.2
  pullPolicy: IfNotPresent
resources: {}
port: 6060
metricsSources:
  kube-state-metrics: http://kube-state-metrics:8080
nodeSelector: {}
tolerations: []
