Skip to content

Commit

Permalink
feat: 💥 deployment.podannotations support interpolation with tpl
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankatliarchuk committed Dec 1, 2023
1 parent cbddacb commit d31b991
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
@@ -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) }}
Expand Down
22 changes: 22 additions & 0 deletions traefik/tests/deployment-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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: {}
# -- Additional Pod labels (e.g. for filtering Pod by custom labels)
podLabels: {}
Expand Down

0 comments on commit d31b991

Please sign in to comment.