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