Skip to content

Commit

Permalink
fix(dashboard): Only set ingressClass annotation when kubernetesCRD p…
Browse files Browse the repository at this point in the history
…rovider is listening for it
  • Loading branch information
mloiseleur authored Jul 2, 2024
1 parent 9665132 commit f142f6c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
16 changes: 16 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,22 @@ extraObjects:
client-secret: "{{ azure_dns_challenge_application_secret }}"
```

# Use an IngressClass

Default install comes with an `IngressClass` resource that can be enabled on providers.

Here's how one can enable it on CRD & Ingress Kubernetes provider:

```yaml
ingressClass:
name: traefik
providers:
kubernetesCRD:
ingressClass: traefik
kubernetesIngress:
ingressClass: traefik
```

# Use HTTP3

By default, it will use a Load balancers with mixed protocols on `websecure`
Expand Down
2 changes: 1 addition & 1 deletion traefik/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Create chart name and version as used by the chart label.
{{/*
Create the chart image name.
*/}}

{{- define "traefik.image-name" -}}
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (.Values.image.tag | default .Chart.AppVersion) }}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
Expand Down
4 changes: 2 additions & 2 deletions traefik/templates/dashboard-ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
name: {{ template "traefik.fullname" . }}-dashboard
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" .) }}
{{- if and .Values.ingressClass.enabled .Values.providers.kubernetesCRD.enabled .Values.providers.kubernetesCRD.ingressClass }}
kubernetes.io/ingress.class: {{ .Values.providers.kubernetesCRD.ingressClass }}
{{- end }}
{{- with .Values.ingressRoute.dashboard.annotations }}
{{- toYaml . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions traefik/templates/healthcheck-ingressroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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" .) }}
{{- if and .Values.ingressClass.enabled .Values.providers.kubernetesCRD.enabled .Values.providers.kubernetesCRD.ingressClass }}
kubernetes.io/ingress.class: {{ .Values.providers.kubernetesCRD.ingressClass }}
{{- end }}
{{- with .Values.ingressRoute.healthcheck.annotations }}
{{- toYaml . | nindent 4 }}
Expand Down
11 changes: 5 additions & 6 deletions traefik/tests/dashboard-ingressroute_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ tests:
options:
name: tls-options
namespace: default
- it: should use the release name as the default ingress class annotation
- it: should not set default ingress class annotation
set:
ingressRoute:
dashboard:
enabled: true
asserts:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: RELEASE-NAME-traefik
value: null
- it: should use the ingress class name for the annotation
set:
ingressRoute:
dashboard:
enabled: true
ingressClass:
name: test-class
providers:
kubernetesCRD:
ingressClass: test-class
asserts:
- equal:
path: metadata.annotations
Expand All @@ -120,6 +120,5 @@ tests:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: RELEASE-NAME-traefik
foo: bar
fis: fas
6 changes: 4 additions & 2 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ providers:
allowExternalNameServices: false
# -- Allows to return 503 when there is no endpoints available
allowEmptyServices: false
# ingressClass: traefik-internal
# -- When the parameter is set, only resources containing an annotation with the same value are processed. Otherwise, resources missing the annotation, having an empty value, or the value traefik are processed. It will also set required annotation on Dashboard and Healthcheck IngressRoute when enabled.
ingressClass:
# labelSelector: environment=production,method=traefik
# -- Array of namespaces to watch. If left empty, Traefik watches all namespaces.
namespaces: []
Expand All @@ -233,7 +234,8 @@ providers:
allowExternalNameServices: false
# -- Allows to return 503 when there is no endpoints available
allowEmptyServices: false
# ingressClass: traefik-internal
# -- When ingressClass is set, only Ingresses containing an annotation with the same value are processed. Otherwise, Ingresses missing the annotation, having an empty value, or the value traefik are processed.
ingressClass:
# labelSelector: environment=production,method=traefik
# -- Array of namespaces to watch. If left empty, Traefik watches all namespaces.
namespaces: []
Expand Down

0 comments on commit f142f6c

Please sign in to comment.