From c3a0c0d7551950f74055aa34d67ba3978c1c34c9 Mon Sep 17 00:00:00 2001 From: Yong Wen Chua Date: Sun, 4 Oct 2020 22:27:04 +0800 Subject: [PATCH] [prometheus-consul-exporter] Support extra containers, environment variables and volumes (#162) * [consul-exporter] Support extra containers and volumes Signed-off-by: Yong Wen Chua * Add environment variables Signed-off-by: Yong Wen Chua * Add Init Container Signed-off-by: Yong Wen Chua * Fix indentation Signed-off-by: Yong Wen Chua --- charts/prometheus-consul-exporter/Chart.yaml | 2 +- .../templates/deployment.yaml | 36 ++++++++++++------- charts/prometheus-consul-exporter/values.yaml | 20 +++++++++++ 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/charts/prometheus-consul-exporter/Chart.yaml b/charts/prometheus-consul-exporter/Chart.yaml index 310be51645bb..500d8c43ab0f 100644 --- a/charts/prometheus-consul-exporter/Chart.yaml +++ b/charts/prometheus-consul-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.4.0" description: A Helm chart for the Prometheus Consul Exporter name: prometheus-consul-exporter -version: 0.1.7 +version: 0.2.0 keywords: - metrics - consul diff --git a/charts/prometheus-consul-exporter/templates/deployment.yaml b/charts/prometheus-consul-exporter/templates/deployment.yaml index 122d7aec5f1f..d156110685d3 100644 --- a/charts/prometheus-consul-exporter/templates/deployment.yaml +++ b/charts/prometheus-consul-exporter/templates/deployment.yaml @@ -20,17 +20,19 @@ spec: release: {{ .Release.Name }} spec: serviceAccountName: {{ template "prometheus-consul-exporter.serviceAccountName" . }} + {{- with .Values.initContainers }} + initContainers: {{ toYaml . | nindent 8 }} + {{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} command: ["consul_exporter"] - args: [ - "--consul.server={{ .Values.consulServer }}", + args: + - "--consul.server={{ .Values.consulServer }}" {{- range $key, $value := .Values.options }} - "--{{ $key }}{{ if $value }}={{ $value }}{{ end }}", + - "--{{ $key }}{{ if $value }}={{ $value }}{{ end }}" {{- end }} - ] ports: - name: http containerPort: {{ .Values.service.port }} @@ -47,17 +49,27 @@ spec: port: http initialDelaySeconds: 30 timeoutSeconds: 10 - resources: -{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.resources }} + resources: {{ toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: {{ toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.extraEnv }} + env: {{ toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.extraContainers }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.nodeSelector }} - nodeSelector: -{{ toYaml . | indent 8 }} + nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} - affinity: -{{ toYaml . | indent 8 }} + affinity: {{ toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} - tolerations: -{{ toYaml . | indent 8 }} + tolerations: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.extraVolumes }} + volumes: {{ toYaml . | nindent 8 }} {{- end }} diff --git a/charts/prometheus-consul-exporter/values.yaml b/charts/prometheus-consul-exporter/values.yaml index 0a8939f5caab..868a7507b599 100644 --- a/charts/prometheus-consul-exporter/values.yaml +++ b/charts/prometheus-consul-exporter/values.yaml @@ -67,3 +67,23 @@ nodeSelector: {} tolerations: [] affinity: {} + +# Extra environment variables +extraEnv: [] + +# Init Containers for Exporter Pod +initContainers: [] + +# Extra containers for the exporter pod +extraContainers: [] + +# Extra Volumes for the pod +extraVolumes: [] +# - name: example +# configMap: +# name: example + +# Extra Volume Mounts for the exporter container +extraVolumeMounts: [] +# - name: example +# mountPath: /example