From 2332c6fb58305d97e9cb3abd3fc5a55578f23974 Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Mon, 15 Jan 2018 08:18:44 -0600 Subject: [PATCH] helm-toolkit prometheus service annotation clean up This adds checks for the fields in the service annotations for prometheus, similar to the pod annotations. It changes the setting of annotations by ingesting a prometheus: key under a top-level monitoring tree to allow for configuration of other monitoring solutions aside from prometheus Change-Id: Id05f235ae07407ea4dcd45bce3a26dd92293b116 --- .../snippets/_prometheus_pod_annotations.tpl | 14 +++++++------- .../_prometheus_service_annotations.tpl | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/helm-toolkit/templates/snippets/_prometheus_pod_annotations.tpl b/helm-toolkit/templates/snippets/_prometheus_pod_annotations.tpl index 5effa77024..9e09326f65 100644 --- a/helm-toolkit/templates/snippets/_prometheus_pod_annotations.tpl +++ b/helm-toolkit/templates/snippets/_prometheus_pod_annotations.tpl @@ -22,14 +22,14 @@ limitations under the License. # pod's declared ports (default is a port-free target if none are declared). {{- define "helm-toolkit.snippets.prometheus_pod_annotations" -}} -{{- $pod := index . 0 -}} -{{- if $pod.prometheus_scrape }} -prometheus.io/scrape: {{ $pod.prometheus_scrape | quote }} +{{- $config := index . 0 -}} +{{- if $config.scrape }} +prometheus.io/scrape: {{ $config.scrape | quote }} {{- end }} -{{- if $pod.prometheus_path }} -prometheus.io/path: {{ $pod.prometheus_path | quote }} +{{- if $config.path }} +prometheus.io/path: {{ $config.path | quote }} {{- end }} -{{- if $pod.prometheus_port }} -prometheus.io/port: {{ $pod.prometheus_port | quote }} +{{- if $config.port }} +prometheus.io/port: {{ $config.port | quote }} {{- end }} {{- end -}} diff --git a/helm-toolkit/templates/snippets/_prometheus_service_annotations.tpl b/helm-toolkit/templates/snippets/_prometheus_service_annotations.tpl index 005ae45d96..1255dccb9d 100644 --- a/helm-toolkit/templates/snippets/_prometheus_service_annotations.tpl +++ b/helm-toolkit/templates/snippets/_prometheus_service_annotations.tpl @@ -21,9 +21,17 @@ limitations under the License. # service then set this appropriately. {{- define "helm-toolkit.snippets.prometheus_service_annotations" -}} -{{- $endpoint := index . 0 -}} -prometheus.io/scrape: {{ $endpoint.scrape | quote }} -prometheus.io/scheme: {{ $endpoint.scheme.default | quote }} -prometheus.io/path: {{ $endpoint.path.default | quote }} -prometheus.io/port: {{ $endpoint.scrape_port | quote }} +{{- $config := index . 0 -}} +{{- if $config.scrape }} +prometheus.io/scrape: {{ $config.scrape | quote }} +{{- end }} +{{- if $config.scheme }} +prometheus.io/scheme: {{ $config.scheme | quote }} +{{- end }} +{{- if $config.path }} +prometheus.io/path: {{ $config.path | quote }} +{{- end }} +{{- if $config.port }} +prometheus.io/port: {{ $config.port | quote }} +{{- end }} {{- end -}}