diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index 8b1f81c05..d168f8d41 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -5,7 +5,7 @@ {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.metrics }} - {{- if .Values.metrics.prometheus }} + {{- if and (.Values.metrics.prometheus) (not .Values.metrics.prometheus.serviceMonitor) }} prometheus.io/scrape: "true" prometheus.io/path: "/metrics" prometheus.io/port: {{ quote (index .Values.ports .Values.metrics.prometheus.entryPoint).port }} diff --git a/traefik/tests/pod-config_test.yaml b/traefik/tests/pod-config_test.yaml index 430fd0765..495de8bb9 100644 --- a/traefik/tests/pod-config_test.yaml +++ b/traefik/tests/pod-config_test.yaml @@ -613,3 +613,12 @@ tests: - equal: path: spec.template.spec.dnsConfig.options[1].name value: "edns0" + - it: should not have prometheus annotations + set: + metrics: + prometheus: + serviceMonitor: + jobLabel: traefik + asserts: + - isNull: + path: spec.template.metadata.annotations.prometheus.io/scrape