Skip to content

Commit

Permalink
feat: use single ingressRoute template
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 committed Jul 24, 2024
1 parent b77d53d commit 9240475
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 81 deletions.
2 changes: 2 additions & 0 deletions traefik/VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ Kubernetes: `>=1.22.0-0`
| ingressRoute.dashboard.labels | object | `{}` | Additional ingressRoute labels (e.g. for filtering IngressRoute by custom labels) |
| ingressRoute.dashboard.matchRule | string | `"PathPrefix(`/dashboard`) || PathPrefix(`/api`)"` | The router match rule used for the dashboard ingressRoute |
| ingressRoute.dashboard.middlewares | list | `[]` | Additional ingressRoute middlewares (e.g. for authentication) |
| ingressRoute.dashboard.services | list | `[{"kind":"TraefikService","name":"api@internal"}]` | The internal service used for the dashboard ingressRoute |
| ingressRoute.dashboard.tls | object | `{}` | TLS options (e.g. secret containing certificate) |
| ingressRoute.healthcheck.annotations | object | `{}` | Additional ingressRoute annotations (e.g. for kubernetes.io/ingress.class) |
| ingressRoute.healthcheck.enabled | bool | `false` | Create an IngressRoute for the healthcheck probe |
| ingressRoute.healthcheck.entryPoints | list | `["traefik"]` | Specify the allowed entrypoints to use for the healthcheck ingress route, (e.g. traefik, web, websecure). By default, it's using traefik entrypoint, which is not exposed. |
| ingressRoute.healthcheck.labels | object | `{}` | Additional ingressRoute labels (e.g. for filtering IngressRoute by custom labels) |
| ingressRoute.healthcheck.matchRule | string | `"PathPrefix(`/ping`)"` | The router match rule used for the healthcheck ingressRoute |
| ingressRoute.healthcheck.middlewares | list | `[]` | Additional ingressRoute middlewares (e.g. for authentication) |
| ingressRoute.healthcheck.services | list | `[{"kind":"TraefikService","name":"ping@internal"}]` | The internal service used for the healthcheck ingressRoute |
| ingressRoute.healthcheck.tls | object | `{}` | TLS options (e.g. secret containing certificate) |
| instanceLabelOverride | string | `nil` | |
| livenessProbe.failureThreshold | int | `3` | The number of consecutive failures allowed before considering the probe as failed. |
Expand Down
39 changes: 0 additions & 39 deletions traefik/templates/dashboard-ingressroute.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions traefik/templates/healthcheck-ingressroute.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions traefik/templates/ingressroute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{ range $name, $config := .Values.ingressRoute }}
{{ if $config.enabled }}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: {{ template "traefik.fullname" $ }}-$name
namespace: {{ template "traefik.namespace" $ }}
annotations:
{{- if and $.Values.ingressClass.enabled $.Values.providers.kubernetesCRD.enabled $.Values.providers.kubernetesCRD.ingressClass }}
kubernetes.io/ingress.class: {{ $.Values.providers.kubernetesCRD.ingressClass }}
{{- end }}
{{- with $config.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "traefik.labels" $ | nindent 4 }}
{{- with $config.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
entryPoints:
{{- range $config.entryPoints }}
- {{ . }}
{{- end }}
routes:
- match: {{ $config.matchRule }}
kind: Rule
{{- with $config.services }}
services:
{{- toYaml . | nindent 6 }}
{{- end -}}
{{- with $config.middlewares }}
middlewares:
{{- toYaml . | nindent 6 }}
{{- end -}}

{{- with $config.tls }}
tls:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{ end }}
2 changes: 1 addition & 1 deletion traefik/tests/common-metadata_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
suite: Resources contains metadata
templates:
- dashboard-ingressroute.yaml
- ingressroute.yaml
- deployment.yaml
- gatewayclass.yaml
- gateway.yaml
Expand Down
2 changes: 1 addition & 1 deletion traefik/tests/dashboard-ingressroute_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
suite: Dashboard IngressRoute configuration
templates:
- dashboard-ingressroute.yaml
- ingressroute.yaml
set:
ingressRoute:
dashboard:
Expand Down
2 changes: 1 addition & 1 deletion traefik/tests/healthcheck-ingressroute_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
suite: healthcheck IngressRoute configuration
templates:
- healthcheck-ingressroute.yaml
- ingressroute.yaml
tests:
- it: should allow enabling healthcheck exposure using ingressRoute
set:
Expand Down
8 changes: 8 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ ingressRoute:
labels: {}
# -- The router match rule used for the dashboard ingressRoute
matchRule: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
# -- The internal service used for the dashboard ingressRoute
services:
- name: api@internal
kind: TraefikService
# -- Specify the allowed entrypoints to use for the dashboard ingress route, (e.g. traefik, web, websecure).
# By default, it's using traefik entrypoint, which is not exposed.
# /!\ Do not expose your dashboard without any protection over the internet /!\
Expand All @@ -178,6 +182,10 @@ ingressRoute:
labels: {}
# -- The router match rule used for the healthcheck ingressRoute
matchRule: PathPrefix(`/ping`)
# -- The internal service used for the healthcheck ingressRoute
services:
- name: ping@internal
kind: TraefikService
# -- Specify the allowed entrypoints to use for the healthcheck ingress route, (e.g. traefik, web, websecure).
# By default, it's using traefik entrypoint, which is not exposed.
entryPoints: ["traefik"]
Expand Down

0 comments on commit 9240475

Please sign in to comment.