Skip to content

Commit

Permalink
fix(IngressClass): provides annotation on IngressRoutes when it's ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
samox73 committed May 28, 2024
1 parent 1435fdd commit f5de0c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
7 changes: 5 additions & 2 deletions traefik/templates/dashboard-ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ kind: IngressRoute
metadata:
name: {{ template "traefik.fullname" . }}-dashboard
namespace: {{ template "traefik.namespace" . }}
{{- with .Values.ingressRoute.dashboard.annotations }}
annotations:
{{- if and .Values.ingressClass.enabled (or .Values.providers.kubernetesCRD.enabled .Values.providers.kubernetesIngress.enabled) }}
kubernetes.io/ingress.class: {{ .Values.ingressClass.name | default (include "traefik.fullname" .) }}
{{- end }}
{{- with .Values.ingressRoute.dashboard.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
{{- include "traefik.labels" . | nindent 4 }}
{{- with .Values.ingressRoute.dashboard.labels }}
Expand Down
3 changes: 3 additions & 0 deletions traefik/templates/healthcheck-ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
name: {{ template "traefik.fullname" . }}-healthcheck
namespace: {{ template "traefik.namespace" . }}
annotations:
{{- if and .Values.ingressClass.enabled (or .Values.providers.kubernetesCRD.enabled .Values.providers.kubernetesIngress.enabled) }}
kubernetes.io/ingress.class: {{ .Values.ingressClass.name | default (include "traefik.fullname" .) }}
{{- end }}
{{- with .Values.ingressRoute.healthcheck.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
19 changes: 17 additions & 2 deletions traefik/tests/dashboard-ingressroute_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,28 @@ tests:
options:
name: tls-options
namespace: default
- it: should not allow to create null annotations
- it: should use the release name as the default ingress class annotation
set:
ingressRoute:
dashboard:
enabled: true
asserts:
- isNull:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: RELEASE-NAME-traefik
- it: should use the ingress class name for the annotation
set:
ingressRoute:
dashboard:
enabled: true
ingressClass:
name: test-class
asserts:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: test-class
- it: should insert annotations correctly
set:
ingressRoute:
Expand All @@ -106,5 +120,6 @@ tests:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: RELEASE-NAME-traefik
foo: bar
fis: fas

0 comments on commit f5de0c3

Please sign in to comment.