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
This commit is contained in:
Steve Wilkerson 2018-01-15 08:18:44 -06:00 committed by Pete Birley
parent 2d2e10bfb7
commit 2332c6fb58
2 changed files with 20 additions and 12 deletions

View File

@ -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 -}}

View File

@ -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 -}}