Skip to content

Commit 7d409fa

Browse files
authored
Added support for multiple host domains. (#249)
1 parent e89d5c9 commit 7d409fa

File tree

6 files changed

+247
-9
lines changed

6 files changed

+247
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.6] - UNRELEASED
9+
10+
### Added
11+
12+
- Added support for multiple hosts in ingress configuration via `ingress.hosts` array [#248](https://github.com/developmentseed/eoapi-k8s/pull/248)
13+
814
## [0.7.5] - 2025-07-11
915

1016
### Changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# We need a separate ingress because browser has the prefix /browser hardcoded in the code
2-
{{- if and .Values.browser.enabled .Values.ingress.enabled }}
2+
{{- if and .Values.browser.enabled .Values.ingress.enabled (or (not (hasKey .Values.browser "ingress")) .Values.browser.ingress.enabled) }}
33
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
44
apiVersion: networking.k8s.io/v1
55
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }}
@@ -30,6 +30,22 @@ spec:
3030
ingressClassName: {{ .Values.ingress.className }}
3131
{{- end }}
3232
rules:
33+
{{- if .Values.ingress.hosts }}
34+
{{- range .Values.ingress.hosts }}
35+
- host: {{ . }}
36+
http:
37+
paths:
38+
{{- 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 }}"
41+
backend:
42+
service:
43+
name: browser-{{ $.Release.Name }}
44+
port:
45+
number: 8080
46+
{{- end }}
47+
{{- end }}
48+
{{- else }}
3349
- {{- if .Values.ingress.host }}
3450
host: {{ .Values.ingress.host }}
3551
{{- end }}
@@ -44,10 +60,17 @@ spec:
4460
port:
4561
number: 8080
4662
{{- end }}
47-
{{- if and .Values.ingress.host .Values.ingress.tls.enabled }}
63+
{{- end }}
64+
{{- if and .Values.ingress.tls.enabled (or .Values.ingress.hosts .Values.ingress.host) }}
4865
tls:
4966
- hosts:
67+
{{- if .Values.ingress.hosts }}
68+
{{- range .Values.ingress.hosts }}
69+
- {{ . }}
70+
{{- end }}
71+
{{- else if .Values.ingress.host }}
5072
- {{ .Values.ingress.host }}
73+
{{- end }}
5174
secretName: {{ .Values.ingress.tls.secretName }}
5275
{{- end }}
5376
{{- end }}

charts/eoapi/templates/services/ingress.yaml

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,62 @@ spec:
2929
ingressClassName: {{ .Values.ingress.className }}
3030
{{- end }}
3131
rules:
32+
{{- if .Values.ingress.hosts }}
33+
{{- range .Values.ingress.hosts }}
34+
- host: {{ . }}
35+
http:
36+
paths:
37+
{{- 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 }}
40+
backend:
41+
service:
42+
name: raster-{{ $.Release.Name }}
43+
port:
44+
number: {{ $.Values.service.port }}
45+
{{- end }}
46+
47+
{{- 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 }}
50+
backend:
51+
service:
52+
name: stac-{{ $.Release.Name }}
53+
port:
54+
number: {{ $.Values.service.port }}
55+
{{- end }}
56+
57+
{{- if and $.Values.vector.enabled (or (not (hasKey $.Values.vector "ingress")) $.Values.vector.ingress.enabled) }}
58+
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
59+
path: {{ $.Values.vector.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
60+
backend:
61+
service:
62+
name: vector-{{ $.Release.Name }}
63+
port:
64+
number: {{ $.Values.service.port }}
65+
{{- end }}
66+
67+
{{- if and $.Values.multidim.enabled (or (not (hasKey $.Values.multidim "ingress")) $.Values.multidim.ingress.enabled) }}
68+
- pathType: {{ if eq $.Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
69+
path: {{ $.Values.multidim.ingress.path }}{{ if eq $.Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
70+
backend:
71+
service:
72+
name: multidim-{{ $.Release.Name }}
73+
port:
74+
number: {{ $.Values.service.port }}
75+
{{- end }}
76+
77+
{{- if $.Values.docServer.enabled }}
78+
- pathType: Prefix
79+
path: "/{{ $.Values.ingress.rootPath | default "" }}"
80+
backend:
81+
service:
82+
name: doc-server-{{ $.Release.Name }}
83+
port:
84+
number: 80
85+
{{- end }}
86+
{{- end }}
87+
{{- else }}
3288
- {{- if .Values.ingress.host }}
3389
host: {{ .Values.ingress.host }}
3490
{{- end }}
@@ -43,7 +99,7 @@ spec:
4399
port:
44100
number: {{ .Values.service.port }}
45101
{{- end }}
46-
102+
47103
{{- if and .Values.stac.enabled (or (not (hasKey .Values.stac "ingress")) .Values.stac.ingress.enabled) }}
48104
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
49105
path: {{ .Values.stac.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
@@ -53,7 +109,7 @@ spec:
53109
port:
54110
number: {{ .Values.service.port }}
55111
{{- end }}
56-
112+
57113
{{- if and .Values.vector.enabled (or (not (hasKey .Values.vector "ingress")) .Values.vector.ingress.enabled) }}
58114
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
59115
path: {{ .Values.vector.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
@@ -63,7 +119,7 @@ spec:
63119
port:
64120
number: {{ .Values.service.port }}
65121
{{- end }}
66-
122+
67123
{{- if and .Values.multidim.enabled (or (not (hasKey .Values.multidim "ingress")) .Values.multidim.ingress.enabled) }}
68124
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
69125
path: {{ .Values.multidim.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
@@ -73,7 +129,7 @@ spec:
73129
port:
74130
number: {{ .Values.service.port }}
75131
{{- end }}
76-
132+
77133
{{- if .Values.docServer.enabled }}
78134
- pathType: Prefix
79135
path: "/{{ $.Values.ingress.rootPath | default "" }}"
@@ -83,10 +139,17 @@ spec:
83139
port:
84140
number: 80
85141
{{- end }}
86-
{{- if and .Values.ingress.host .Values.ingress.tls.enabled }}
142+
{{- end }}
143+
{{- if and .Values.ingress.tls.enabled (or .Values.ingress.hosts .Values.ingress.host) }}
87144
tls:
88145
- hosts:
146+
{{- if .Values.ingress.hosts }}
147+
{{- range .Values.ingress.hosts }}
148+
- {{ . }}
149+
{{- end }}
150+
{{- else if .Values.ingress.host }}
89151
- {{ .Values.ingress.host }}
152+
{{- end }}
90153
secretName: {{ .Values.ingress.tls.secretName }}
91154
{{- end }}
92155
{{- end }}

charts/eoapi/tests/ingress_tests.yaml

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tests:
6464
- equal:
6565
path: spec.rules[0].host
6666
value: "eoapi.local"
67-
67+
6868
- it: "multidim ingress in production (non-testing) with traefik controller"
6969
set:
7070
ingress.className: "traefik"
@@ -153,3 +153,140 @@ tests:
153153
value:
154154
traefik.ingress.kubernetes.io/router.entrypoints: web
155155
traefik.ingress.kubernetes.io/router.middlewares: NAMESPACE-strip-prefix-middleware-RELEASE-NAME@kubernetescrd
156+
157+
- it: "multiple hosts with nginx controller"
158+
set:
159+
ingress.className: "nginx"
160+
ingress.hosts:
161+
- "2.eoapi.dev"
162+
- "1.eoapi.dev"
163+
raster.enabled: true
164+
stac.enabled: true
165+
vector.enabled: false
166+
multidim.enabled: false
167+
browser.enabled: false
168+
asserts:
169+
- isKind:
170+
of: Ingress
171+
- equal:
172+
path: spec.rules[0].host
173+
value: "2.eoapi.dev"
174+
- equal:
175+
path: spec.rules[1].host
176+
value: "1.eoapi.dev"
177+
- equal:
178+
path: spec.rules[0].http.paths[0].path
179+
value: "/raster(/|$)(.*)"
180+
- equal:
181+
path: spec.rules[0].http.paths[1].path
182+
value: "/stac(/|$)(.*)"
183+
- equal:
184+
path: spec.rules[1].http.paths[0].path
185+
value: "/raster(/|$)(.*)"
186+
- equal:
187+
path: spec.rules[1].http.paths[1].path
188+
value: "/stac(/|$)(.*)"
189+
190+
- it: "multiple hosts with traefik controller"
191+
set:
192+
ingress.className: "traefik"
193+
ingress.hosts:
194+
- "2.eoapi.dev"
195+
- "1.eoapi.dev"
196+
raster.enabled: false
197+
stac.enabled: true
198+
vector.enabled: false
199+
multidim.enabled: false
200+
browser.enabled: false
201+
asserts:
202+
- isKind:
203+
of: Ingress
204+
- equal:
205+
path: spec.rules[0].host
206+
value: "2.eoapi.dev"
207+
- equal:
208+
path: spec.rules[1].host
209+
value: "1.eoapi.dev"
210+
- equal:
211+
path: spec.rules[0].http.paths[0].path
212+
value: "/stac"
213+
- equal:
214+
path: spec.rules[0].http.paths[0].pathType
215+
value: "Prefix"
216+
- equal:
217+
path: spec.rules[1].http.paths[0].path
218+
value: "/stac"
219+
- equal:
220+
path: spec.rules[1].http.paths[0].pathType
221+
value: "Prefix"
222+
223+
- it: "multiple hosts with TLS enabled"
224+
set:
225+
ingress.className: "nginx"
226+
ingress.hosts:
227+
- "2.eoapi.dev"
228+
- "1.eoapi.dev"
229+
ingress.tls.enabled: true
230+
ingress.tls.secretName: "eoapi-tls"
231+
raster.enabled: false
232+
stac.enabled: true
233+
vector.enabled: false
234+
multidim.enabled: false
235+
browser.enabled: false
236+
asserts:
237+
- isKind:
238+
of: Ingress
239+
- equal:
240+
path: spec.tls[0].hosts[0]
241+
value: "2.eoapi.dev"
242+
- equal:
243+
path: spec.tls[0].hosts[1]
244+
value: "1.eoapi.dev"
245+
- equal:
246+
path: spec.tls[0].secretName
247+
value: "eoapi-tls"
248+
249+
- it: "single host (default)"
250+
set:
251+
ingress.className: "nginx"
252+
ingress.host: "1.eoapi.dev"
253+
ingress.tls.enabled: true
254+
ingress.tls.secretName: "eoapi-tls"
255+
raster.enabled: false
256+
stac.enabled: true
257+
vector.enabled: false
258+
multidim.enabled: false
259+
browser.enabled: false
260+
asserts:
261+
- isKind:
262+
of: Ingress
263+
- equal:
264+
path: spec.rules[0].host
265+
value: "1.eoapi.dev"
266+
- equal:
267+
path: spec.tls[0].hosts[0]
268+
value: "1.eoapi.dev"
269+
- equal:
270+
path: spec.tls[0].secretName
271+
value: "eoapi-tls"
272+
273+
- it: "hosts array takes precedence over single host"
274+
set:
275+
ingress.className: "nginx"
276+
ingress.host: "should-be-ignored.com"
277+
ingress.hosts:
278+
- "1.eoapi.dev"
279+
raster.enabled: false
280+
stac.enabled: true
281+
vector.enabled: false
282+
multidim.enabled: false
283+
browser.enabled: false
284+
asserts:
285+
- isKind:
286+
of: Ingress
287+
- equal:
288+
path: spec.rules[0].host
289+
value: "1.eoapi.dev"
290+
- notEqual:
291+
path: spec.rules[0].host
292+
value: "should-be-ignored.com"

charts/eoapi/values.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
"type": "string",
7878
"description": "Ingress host"
7979
},
80+
"hosts": {
81+
"type": "array",
82+
"items": {
83+
"type": "string"
84+
},
85+
"description": "Array of multiple ingress host domains array - if specified, takes precedence over single host"
86+
},
8087
"annotations": {
8188
"type": "object",
8289
"description": "Additional annotations for ingress"

charts/eoapi/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ ingress:
4242
# ingressClassName: "nginx" or "traefik"
4343
className: "nginx"
4444
rootPath: "" # Root path for doc server
45-
# Host configuration
45+
# Single host domain configuration (default)
4646
host: ""
47+
# Multiple host domains array - if specified, takes precedence over single host
48+
# hosts: []
4749
# Custom annotations to add to the ingress
4850
annotations: {}
4951
# TLS configuration

0 commit comments

Comments
 (0)