From 50b8ee6114b0b0f567d3a8d6956872c465506054 Mon Sep 17 00:00:00 2001 From: ivan katliarchuk Date: Fri, 24 Nov 2023 23:38:50 +0000 Subject: [PATCH 1/2] feat: deployment.podannotations support tpl interpolation Signed-off-by: ivan katliarchuk --- traefik/templates/_podtemplate.tpl | 4 ++-- traefik/tests/deployment-config_test.yaml | 22 ++++++++++++++++++++++ traefik/values.yaml | 2 ++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index cbf195d7d..cd2aa2294 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -1,8 +1,8 @@ {{- define "traefik.podTemplate" }} metadata: annotations: - {{- with .Values.deployment.podAnnotations }} - {{- toYaml . | nindent 8 }} + {{- if .Values.deployment.podAnnotations }} + {{- tpl (toYaml .Values.deployment.podAnnotations) . | nindent 8 }} {{- end }} {{- if .Values.metrics }} {{- if and (.Values.metrics.prometheus) (not .Values.metrics.prometheus.serviceMonitor) }} diff --git a/traefik/tests/deployment-config_test.yaml b/traefik/tests/deployment-config_test.yaml index c9bbda5dd..5c1a5c824 100644 --- a/traefik/tests/deployment-config_test.yaml +++ b/traefik/tests/deployment-config_test.yaml @@ -67,6 +67,28 @@ tests: - equal: path: spec.template.metadata.annotations.traefik/powpow value: podAnnotations + - it: should have podAnnotations with specified values + set: + type: 'internal' + deployment: + podAnnotations: + traefik/powpow: podAnnotations + traefik/name: '{{ template "traefik.name" . }}' + traefik/{{ template "traefik.name" . }}.logs: 'log_processing_rules' + traefik/type: '{{ .Values.type }}' + asserts: + - equal: + path: spec.template.metadata.annotations.traefik/powpow + value: podAnnotations + - equal: + path: spec.template.metadata.annotations.traefik/name + value: 'traefik' + - equal: + path: spec.template.metadata.annotations["traefik/traefik.logs"] + value: 'log_processing_rules' + - equal: + path: spec.template.metadata.annotations.traefik/type + value: 'internal' - it: should have labels with specified values set: deployment: diff --git a/traefik/values.yaml b/traefik/values.yaml index ba3174c3c..bec492a55 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -41,6 +41,8 @@ deployment: labels: {} # -- Additional pod annotations (e.g. for mesh injection or prometheus scraping) podAnnotations: {} + # traefik/name: '{{ template "traefik.name" . }}' + # -- Additional Pod labels (e.g. for filtering Pod by custom labels) podLabels: {} # -- Additional containers (e.g. for metric offloading sidecars) From 0eeede6ebd23ee55893ee31fbe6cc5d806c4c722 Mon Sep 17 00:00:00 2001 From: Ivan Katliarchuk <5395690+ivankatliarchuk@users.noreply.github.com> Date: Mon, 27 Nov 2023 07:29:35 -0800 Subject: [PATCH 2/2] Update traefik/values.yaml linter fixes Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> --- traefik/values.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/traefik/values.yaml b/traefik/values.yaml index bec492a55..dd6cd4c36 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -40,9 +40,8 @@ deployment: # -- Additional deployment labels (e.g. for filtering deployment by custom labels) labels: {} # -- Additional pod annotations (e.g. for mesh injection or prometheus scraping) + # It supports templating. One can set it with values like traefik/name: '{{ template "traefik.name" . }}' podAnnotations: {} - # traefik/name: '{{ template "traefik.name" . }}' - # -- Additional Pod labels (e.g. for filtering Pod by custom labels) podLabels: {} # -- Additional containers (e.g. for metric offloading sidecars)