Skip to content

Commit 2cd2c70

Browse files
committed
Moved to traefik for default ingress.
1 parent d0bbe96 commit 2cd2c70

File tree

14 files changed

+145
-85
lines changed

14 files changed

+145
-85
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Added support for annotations on the PgSTAC bootstrap job via `pgstacBootstrap.jobAnnotations` in values.yaml [#381](https://github.com/developmentseed/eoapi-k8s/pull/381)
1313

14+
### Changed
15+
16+
- Moved to traefik for the default ingress solution [#384](https://github.com/developmentseed/eoapi-k8s/pull/384)
17+
1418
### Fixed
1519

1620
- Fixed Helm template to check queryables `file` field with schema validation [#380](https://github.com/developmentseed/eoapi-k8s/pull/380)

charts/eoapi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ apiServices:
9898
# Configure ingress
9999
ingress:
100100
enabled: true
101-
className: "nginx" # or "traefik"
101+
className: "traefik" # Default, or "nginx" for legacy setups
102102
host: "your-domain.com" # Optional
103103

104104
# Database options

charts/eoapi/profiles/core.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ observability:
167167
######################
168168
ingress:
169169
enabled: true
170-
className: "nginx"
170+
className: "traefik" # Traefik with nginx provider support
171171
pathType: "Prefix"
172172
host: ""
173173
tls:

charts/eoapi/profiles/experimental.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ autoscaling:
358358
######################
359359
ingress:
360360
enabled: true
361-
className: "nginx"
361+
className: "traefik" # Traefik with nginx provider support
362362
pathType: "Prefix"
363363
host: "localhost"
364364
tls:

charts/eoapi/profiles/production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ knative:
343343
######################
344344
ingress:
345345
enabled: true
346-
className: "nginx"
346+
className: "traefik" # Traefik with nginx provider support
347347
pathType: "Prefix"
348348
host: "eoapi.example.com" # CHANGE THIS to your domain
349349
tls:

charts/eoapi/templates/networking/ingress-browser.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ metadata:
1616
{{- if .Values.ingress.annotations }}
1717
{{ toYaml .Values.ingress.annotations | indent 4 }}
1818
{{- end }}
19-
{{- if eq .Values.ingress.className "nginx" }}
19+
# Use nginx annotations for both nginx and traefik
20+
# Traefik 3.5+ understands nginx annotations via the nginx provider
21+
{{- if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}
2022
nginx.ingress.kubernetes.io/rewrite-target: /browser/$2
2123
nginx.ingress.kubernetes.io/use-regex: "true"
2224
{{- end }}
23-
# Temporary annotations for Traefik until uvicorn support real prefix in ASGI: https://github.com/encode/uvicorn/discussions/2490
24-
{{- if eq .Values.ingress.className "traefik" }}
25-
traefik.ingress.kubernetes.io/router.entrypoints: web
26-
traefik.ingress.kubernetes.io/router.middlewares: {{ $.Release.Namespace }}-{{ $.Release.Name }}-strip-prefix-middleware@kubernetescrd
27-
{{- end }}
2825
spec:
2926
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
3027
ingressClassName: {{ .Values.ingress.className }}
@@ -36,8 +33,8 @@ spec:
3633
http:
3734
paths:
3835
{{- if and $.Values.browser.enabled (or (not (hasKey $.Values.browser "ingress")) $.Values.browser.ingress.enabled) }}
39-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
40-
path: "/browser{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}"
36+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
37+
path: "/browser{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}"
4138
backend:
4239
service:
4340
name: {{ .Release.Name }}-browser
@@ -52,8 +49,8 @@ spec:
5249
http:
5350
paths:
5451
{{- if and .Values.browser.enabled (or (not (hasKey .Values.browser "ingress")) .Values.browser.ingress.enabled) }}
55-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
56-
path: "/browser{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}"
52+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
53+
path: "/browser{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}"
5754
backend:
5855
service:
5956
name: {{ .Release.Name }}-browser

charts/eoapi/templates/networking/ingress.yaml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ metadata:
1212
labels:
1313
app: {{ .Release.Name }}-ingress
1414
annotations:
15-
{{- if eq .Values.ingress.className "nginx" }}
15+
# Use nginx annotations for both nginx and traefik
16+
# Traefik 3.5+ understands nginx annotations via the nginx provider
17+
# Ensure Traefik is deployed with --experimental.kubernetesIngressNGINX and --providers.kubernetesIngressNGINX
18+
{{- if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}
1619
nginx.ingress.kubernetes.io/rewrite-target: /$2
1720
nginx.ingress.kubernetes.io/use-regex: "true"
1821
{{- end }}
1922
{{- if .Values.ingress.annotations }}
2023
{{ toYaml .Values.ingress.annotations | indent 4 }}
2124
{{- end }}
22-
# Temporary annotations for Traefik until uvicorn support real prefix in ASGI: https://github.com/encode/uvicorn/discussions/2490
23-
{{- if eq .Values.ingress.className "traefik" }}
24-
traefik.ingress.kubernetes.io/router.entrypoints: web
25-
traefik.ingress.kubernetes.io/router.middlewares: {{ $.Release.Namespace }}-{{ $.Release.Name }}-strip-prefix-middleware@kubernetescrd
26-
{{- end }}
2725
spec:
2826
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
2927
ingressClassName: {{ .Values.ingress.className }}
@@ -35,8 +33,8 @@ spec:
3533
http:
3634
paths:
3735
{{- if and $.Values.raster.enabled (or (not (hasKey $.Values.raster "ingress")) $.Values.raster.ingress.enabled) }}
38-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
39-
path: {{ $.Values.raster.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
36+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
37+
path: {{ $.Values.raster.ingress.path }}{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
4038
backend:
4139
service:
4240
name: {{ $.Release.Name }}-raster
@@ -45,8 +43,8 @@ spec:
4543
{{- end }}
4644

4745
{{- if and $.Values.stac.enabled (or (not (hasKey $.Values.stac "ingress")) $.Values.stac.ingress.enabled) }}
48-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
49-
path: {{ $.Values.stac.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
46+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
47+
path: {{ $.Values.stac.ingress.path }}{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
5048
backend:
5149
service:
5250
{{- if index $.Values "stac-auth-proxy" "enabled" }}
@@ -59,8 +57,8 @@ spec:
5957
{{- end }}
6058

6159
{{- if and $.Values.vector.enabled (or (not (hasKey $.Values.vector "ingress")) $.Values.vector.ingress.enabled) }}
62-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
63-
path: {{ $.Values.vector.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
60+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
61+
path: {{ $.Values.vector.ingress.path }}{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
6462
backend:
6563
service:
6664
name: {{ $.Release.Name }}-vector
@@ -69,8 +67,8 @@ spec:
6967
{{- end }}
7068

7169
{{- if and $.Values.multidim.enabled (or (not (hasKey $.Values.multidim "ingress")) $.Values.multidim.ingress.enabled) }}
72-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
73-
path: {{ $.Values.multidim.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
70+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
71+
path: {{ $.Values.multidim.ingress.path }}{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
7472
backend:
7573
service:
7674
name: {{ $.Release.Name }}-multidim
@@ -79,8 +77,8 @@ spec:
7977
{{- end }}
8078

8179
{{- if and $.Values.mockOidcServer.enabled $.Values.mockOidcServer.ingress.enabled }}
82-
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
83-
path: {{ $.Values.mockOidcServer.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
80+
- pathType: {{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
81+
path: {{ $.Values.mockOidcServer.ingress.path }}{{ if or (eq $.Values.ingress.className "nginx") (eq $.Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
8482
backend:
8583
service:
8684
name: {{ $.Release.Name }}-mock-oidc-server
@@ -105,8 +103,8 @@ spec:
105103
http:
106104
paths:
107105
{{- if and .Values.raster.enabled (or (not (hasKey .Values.raster "ingress")) .Values.raster.ingress.enabled) }}
108-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
109-
path: {{ .Values.raster.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
106+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
107+
path: {{ .Values.raster.ingress.path }}{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
110108
backend:
111109
service:
112110
name: {{ .Release.Name }}-raster
@@ -115,8 +113,8 @@ spec:
115113
{{- end }}
116114

117115
{{- if and .Values.stac.enabled (or (not (hasKey .Values.stac "ingress")) .Values.stac.ingress.enabled) }}
118-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
119-
path: {{ .Values.stac.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
116+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
117+
path: {{ .Values.stac.ingress.path }}{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
120118
backend:
121119
service:
122120
{{- if index .Values "stac-auth-proxy" "enabled" }}
@@ -129,8 +127,8 @@ spec:
129127
{{- end }}
130128

131129
{{- if and .Values.vector.enabled (or (not (hasKey .Values.vector "ingress")) .Values.vector.ingress.enabled) }}
132-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
133-
path: {{ .Values.vector.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
130+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
131+
path: {{ .Values.vector.ingress.path }}{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
134132
backend:
135133
service:
136134
name: {{ .Release.Name }}-vector
@@ -139,8 +137,8 @@ spec:
139137
{{- end }}
140138

141139
{{- if and .Values.multidim.enabled (or (not (hasKey .Values.multidim "ingress")) .Values.multidim.ingress.enabled) }}
142-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
143-
path: {{ .Values.multidim.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
140+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
141+
path: {{ .Values.multidim.ingress.path }}{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
144142
backend:
145143
service:
146144
name: {{ .Release.Name }}-multidim
@@ -149,8 +147,8 @@ spec:
149147
{{- end }}
150148

151149
{{- if and .Values.mockOidcServer.enabled .Values.mockOidcServer.ingress.enabled }}
152-
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
153-
path: {{ .Values.mockOidcServer.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
150+
- pathType: {{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}ImplementationSpecific{{ else }}Prefix{{ end }}
151+
path: {{ .Values.mockOidcServer.ingress.path }}{{ if or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik") }}(/|$)(.*){{ end }}
154152
backend:
155153
service:
156154
name: {{ .Release.Name }}-mock-oidc-server

charts/eoapi/templates/networking/traefik-middleware.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{{- if and .Values.ingress.enabled (eq .Values.ingress.className "traefik") }}
2+
{{- /*
3+
NOTE: This middleware is not needed when using Traefik's nginx provider with nginx annotations.
4+
The nginx annotations (nginx.ingress.kubernetes.io/rewrite-target) handle path rewrites.
5+
This middleware is kept for backward compatibility or if using pure Traefik mode without nginx provider.
6+
*/}}
27
apiVersion: traefik.io/v1alpha1
38
kind: Middleware
49
metadata:

charts/eoapi/tests/ingress_tests.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ tests:
3333
path: spec.ingressClassName
3434
value: "nginx"
3535

36-
- it: "stac ingress with traefik controller"
36+
- it: "stac ingress with traefik controller (using nginx provider)"
3737
set:
3838
ingress.className: "traefik"
39-
ingress.pathType: "Prefix"
4039
ingress.host: "eoapi.local"
4140
raster.enabled: false
4241
stac.enabled: true
@@ -48,15 +47,15 @@ tests:
4847
of: Ingress
4948
- equal:
5049
path: spec.rules[0].http.paths[0].path
51-
value: "/stac"
50+
value: "/stac(/|$)(.*)"
5251
- equal:
5352
path: spec.rules[0].http.paths[0].pathType
54-
value: "Prefix"
53+
value: "ImplementationSpecific"
5554
- equal:
5655
path: metadata.annotations
5756
value:
58-
traefik.ingress.kubernetes.io/router.entrypoints: web
59-
traefik.ingress.kubernetes.io/router.middlewares: NAMESPACE-RELEASE-NAME-strip-prefix-middleware@kubernetescrd
57+
nginx.ingress.kubernetes.io/rewrite-target: /$2
58+
nginx.ingress.kubernetes.io/use-regex: "true"
6059
- equal:
6160
path: spec.ingressClassName
6261
value: "traefik"

charts/eoapi/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ service:
3232

3333
ingress:
3434
# Unified ingress configuration for both nginx and traefik
35+
# Traefik 3.5+ supports nginx annotations via the nginx provider
36+
# Set --experimental.kubernetesIngressNGINX and --providers.kubernetesIngressNGINX when deploying Traefik
3537
enabled: true
3638
# ingressClassName: "nginx" or "traefik"
37-
className: "nginx"
39+
className: "traefik"
3840
rootPath: "" # Root path for doc server
3941
# Single host domain configuration (default)
4042
host: ""

0 commit comments

Comments
 (0)