Skip to content

Commit

Permalink
feat: ✨ add healthcheck ingressRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
muandane authored Oct 3, 2023
1 parent 498c1e7 commit 0725e48
Show file tree
Hide file tree
Showing 4 changed files with 491 additions and 330 deletions.
36 changes: 36 additions & 0 deletions traefik/templates/healthcheck-ingressroute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.ingressRoute.healthcheck.enabled -}}
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: {{ template "traefik.fullname" . }}-healthcheck
namespace: {{ template "traefik.namespace" . }}
annotations:
{{- with .Values.ingressRoute.healthcheck.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "traefik.labels" . | nindent 4 }}
{{- with .Values.ingressRoute.healthcheck.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
entryPoints:
{{- range .Values.ingressRoute.healthcheck.entryPoints }}
- {{ . }}
{{- end }}
routes:
- match: {{ .Values.ingressRoute.healthcheck.matchRule }}
kind: Rule
services:
- name: ping@internal
kind: TraefikService
{{- with .Values.ingressRoute.healthcheck.middlewares }}
middlewares:
{{- toYaml . | nindent 6 }}
{{- end -}}

{{- with .Values.ingressRoute.healthcheck.tls }}
tls:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
170 changes: 85 additions & 85 deletions traefik/tests/dashboard-ingressroute_test.yaml
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
suite: Dashboard IngressRoute configuration
templates:
- dashboard-ingressroute.yaml
- dashboard-ingressroute.yaml
tests:
- it: should allow disabling dashboard exposure using ingressRoute
set:
ingressRoute:
dashboard:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: should have the expected default route match rule
asserts:
- equal:
path: spec.routes[0].match
value: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
- it: should support overwriting the route match rule
set:
ingressRoute:
dashboard:
matchRule: Host(`traefik.example.com`)
asserts:
- equal:
path: spec.routes[0].match
value: Host(`traefik.example.com`)
- it: should have traefik as default entryPoints
asserts:
- equal:
path: spec.entryPoints
value: ["traefik"]
- it: should support setting websecure as entryPoint
set:
ingressRoute:
dashboard:
entryPoints: ["websecure"]
asserts:
- equal:
path: spec.entryPoints
value: ["websecure"]
- it: should support adding specific label on IngressRoute
set:
ingressRoute:
dashboard:
labels:
foo: bar
asserts:
- equal:
path: metadata.labels.foo
value: bar
- it: should not have middlewares by default
asserts:
- isNull:
path: spec.routes[0].middlewares
- it: should support adding middlewares
set:
ingressRoute:
dashboard:
middlewares:
- name: traefik-dashboard-auth
namespace: default
asserts:
- equal:
path: spec.routes[0].middlewares
value:
- name: traefik-dashboard-auth
namespace: default
- it: should not have tls options by default
asserts:
- isNull:
path: spec.tls
- it: should support adding tls options
set:
ingressRoute:
dashboard:
tls:
secretName: traefik-dashboard-auth
options:
name: tls-options
namespace: default
asserts:
- equal:
path: spec.tls
value:
secretName: traefik-dashboard-auth
options:
name: tls-options
namespace: default
- it: should allow disabling dashboard exposure using ingressRoute
set:
ingressRoute:
dashboard:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: should have the expected default route match rule
asserts:
- equal:
path: spec.routes[0].match
value: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
- it: should support overwriting the route match rule
set:
ingressRoute:
dashboard:
matchRule: Host(`traefik.example.com`)
asserts:
- equal:
path: spec.routes[0].match
value: Host(`traefik.example.com`)
- it: should have traefik as default entryPoints
asserts:
- equal:
path: spec.entryPoints
value: ["traefik"]
- it: should support setting websecure as entryPoint
set:
ingressRoute:
dashboard:
entryPoints: ["websecure"]
asserts:
- equal:
path: spec.entryPoints
value: ["websecure"]
- it: should support adding specific label on IngressRoute
set:
ingressRoute:
dashboard:
labels:
foo: bar
asserts:
- equal:
path: metadata.labels.foo
value: bar
- it: should not have middlewares by default
asserts:
- isNull:
path: spec.routes[0].middlewares
- it: should support adding middlewares
set:
ingressRoute:
dashboard:
middlewares:
- name: traefik-dashboard-auth
namespace: default
asserts:
- equal:
path: spec.routes[0].middlewares
value:
- name: traefik-dashboard-auth
namespace: default
- it: should not have tls options by default
asserts:
- isNull:
path: spec.tls
- it: should support adding tls options
set:
ingressRoute:
dashboard:
tls:
secretName: traefik-dashboard-auth
options:
name: tls-options
namespace: default
asserts:
- equal:
path: spec.tls
value:
secretName: traefik-dashboard-auth
options:
name: tls-options
namespace: default
109 changes: 109 additions & 0 deletions traefik/tests/healthcheck-ingressroute_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
suite: healthcheck IngressRoute configuration
templates:
- healthcheck-ingressroute.yaml
tests:
- it: should allow enabling healthcheck exposure using ingressRoute
set:
ingressRoute:
healthcheck:
enabled: true
asserts:
- hasDocuments:
count: 1
- it: should have the expected default route match rule
set:
ingressRoute:
healthcheck:
enabled: true
asserts:
- equal:
path: spec.routes[0].match
value: PathPrefix(`/ping`)
- it: should support overwriting the route match rule
set:
ingressRoute:
healthcheck:
enabled: true
matchRule: Host(`traefik.example.com`)
asserts:
- equal:
path: spec.routes[0].match
value: Host(`traefik.example.com`)
- it: should have traefik as default entryPoints
set:
ingressRoute:
healthcheck:
enabled: true
asserts:
- equal:
path: spec.entryPoints
value: ["traefik"]
- it: should support setting websecure as entryPoint
set:
ingressRoute:
healthcheck:
entryPoints: ["websecure"]
enabled: true
asserts:
- equal:
path: spec.entryPoints
value: ["websecure"]
- it: should support adding specific label on IngressRoute
set:
ingressRoute:
healthcheck:
enabled: true
labels:
foo: bar
asserts:
- equal:
path: metadata.labels.foo
value: bar
- it: should not have middlewares by default
set:
ingressRoute:
healthcheck:
enabled: true
asserts:
- isNull:
path: spec.routes[0].middlewares
- it: should support adding middlewares
set:
ingressRoute:
healthcheck:
enabled: true
middlewares:
- name: traefik-healthcheck-auth
namespace: default
asserts:
- equal:
path: spec.routes[0].middlewares
value:
- name: traefik-healthcheck-auth
namespace: default
- it: should not have tls options by default
set:
ingressRoute:
healthcheck:
enabled: true
asserts:
- isNull:
path: spec.tls
- it: should support adding tls options
set:
ingressRoute:
healthcheck:
enabled: true
tls:
secretName: traefik-healthcheck-auth
options:
name: tls-options
namespace: default
asserts:
- equal:
path: spec.tls
value:
secretName: traefik-healthcheck-auth
options:
name: tls-options
namespace: default
Loading

0 comments on commit 0725e48

Please sign in to comment.