Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions .github/workflows/tests/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def test_stac_api(stac_endpoint):
# Ping
assert client.get(f"{stac_endpoint}/_mgmt/ping").status_code == 200

# Landing page
resp = client.get(stac_endpoint)
assert resp.status_code == 200
landing = resp.json()
# Verify landing page links have correct base path
for link in landing["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(stac_endpoint.split("://")[1])

# viewer
#assert client.get(f"{stac_endpoint}/index.html").status_code == 200
assert client.get(f"{stac_endpoint}/index.html").status_code == 404
Expand All @@ -26,11 +35,21 @@ def test_stac_api(stac_endpoint):
ids = [c["id"] for c in collections]
assert "noaa-emergency-response" in ids

# Verify collection links have correct base path
for collection in collections:
for link in collection["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(stac_endpoint.split("://")[1])

# items
resp = client.get(f"{stac_endpoint}/collections/noaa-emergency-response/items")
assert resp.status_code == 200
items = resp.json()["features"]
assert len(items) == 10
items = resp.json()
# Verify item links have correct base path
for feature in items["features"]:
for link in feature["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(stac_endpoint.split("://")[1])

# item
resp = client.get(
Expand All @@ -51,6 +70,45 @@ def test_stac_to_raster(stac_endpoint):
#assert resp.status_code == 307
assert resp.status_code == 404

def test_stac_custom_path(stac_endpoint):
"""test stac with custom ingress path."""
# If we're using a custom path (e.g., /api instead of /stac)
base_path = stac_endpoint.split("://")[1]

# Landing page
resp = client.get(stac_endpoint)
assert resp.status_code == 200
landing = resp.json()

# All links should use the custom path
for link in landing["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(base_path), \
f"Link {link['href']} doesn't start with {base_path}"

# Collections should also use the custom path
resp = client.get(f"{stac_endpoint}/collections")
assert resp.status_code == 200
collections = resp.json()["collections"]

for collection in collections:
for link in collection["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(base_path), \
f"Collection link {link['href']} doesn't start with {base_path}"

# Test a specific item
resp = client.get(f"{stac_endpoint}/collections/noaa-emergency-response/items")
assert resp.status_code == 200
items = resp.json()

# Item links should also use the custom path
for feature in items["features"]:
for link in feature["links"]:
if link["href"].startswith("/"):
assert link["href"].startswith(base_path), \
f"Item link {link['href']} doesn't start with {base_path}"

# viewer
resp = client.get(
f"{stac_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/viewer",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ spec:
- containerPort: 8080
env:
- name: SB_catalogUrl
value: "/stac"
value: "{{ .Values.stac.ingress.path }}"
{{- end }}
8 changes: 4 additions & 4 deletions helm-chart/eoapi/templates/services/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
paths:
{{- if and .Values.raster.enabled (or (not (hasKey .Values.raster "ingress")) .Values.raster.ingress.enabled) }}
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
path: /raster{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
path: {{ .Values.raster.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
backend:
service:
name: raster-{{ $.Release.Name }}
Expand All @@ -46,7 +46,7 @@ spec:

{{- if and .Values.stac.enabled (or (not (hasKey .Values.stac "ingress")) .Values.stac.ingress.enabled) }}
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
path: /stac{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
path: {{ .Values.stac.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
backend:
service:
name: stac-{{ $.Release.Name }}
Expand All @@ -56,7 +56,7 @@ spec:

{{- if and .Values.vector.enabled (or (not (hasKey .Values.vector "ingress")) .Values.vector.ingress.enabled) }}
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
path: /vector{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
path: {{ .Values.vector.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
backend:
service:
name: vector-{{ $.Release.Name }}
Expand All @@ -66,7 +66,7 @@ spec:

{{- if and .Values.multidim.enabled (or (not (hasKey .Values.multidim "ingress")) .Values.multidim.ingress.enabled) }}
- pathType: {{ if eq .Values.ingress.className "nginx" }}ImplementationSpecific{{ else }}Prefix{{ end }}
path: /multidim{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
path: {{ .Values.multidim.ingress.path }}{{ if eq .Values.ingress.className "nginx" }}(/|$)(.*){{ end }}
backend:
service:
name: multidim-{{ $.Release.Name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if (and (.Values.ingress.className) (or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik"))) }}
- "--proxy-headers"
- "--forwarded-allow-ips=*"
- "--root-path=/multidim"
- "--root-path={{ .Values.multidim.ingress.path }}"
{{- end }}{{/* needed for proxies and path rewrites on NLB */}}
livenessProbe:
tcpSocket:
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/eoapi/templates/services/raster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if (and (.Values.ingress.className) (or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik"))) }}
- "--proxy-headers"
- "--forwarded-allow-ips=*"
- "--root-path=/raster"
- "--root-path={{ .Values.raster.ingress.path }}"
{{- end }}{{/* needed for proxies and path rewrites on NLB */}}
livenessProbe:
tcpSocket:
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/eoapi/templates/services/stac/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if (and (.Values.ingress.className) (or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik"))) }}
- "--proxy-headers"
- "--forwarded-allow-ips=*"
- "--root-path=/stac"
- "--root-path={{ .Values.stac.ingress.path }}"
{{- end }}{{/* needed for proxies and path rewrites on NLB */}}
livenessProbe:
tcpSocket:
Expand Down
8 changes: 4 additions & 4 deletions helm-chart/eoapi/templates/services/traefik-middleware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ spec:
stripPrefix:
prefixes:
{{- if .Values.raster.enabled }}
- /raster
- {{ .Values.raster.ingress.path }}
{{- end }}
{{- if .Values.stac.enabled }}
- /stac
- {{ .Values.stac.ingress.path }}
{{- end }}
{{- if .Values.vector.enabled }}
- /vector
- {{ .Values.vector.ingress.path }}
{{- end }}
{{- if .Values.multidim.enabled }}
- /multidim
- {{ .Values.multidim.ingress.path }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion helm-chart/eoapi/templates/services/vector/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if (and (.Values.ingress.className) (or (eq .Values.ingress.className "nginx") (eq .Values.ingress.className "traefik"))) }}
- "--proxy-headers"
- "--forwarded-allow-ips=*"
- "--root-path=/vector"
- "--root-path={{ .Values.vector.ingress.path }}"
{{- end }}{{/* needed for proxies and path rewrites on NLB */}}
livenessProbe:
tcpSocket:
Expand Down
62 changes: 62 additions & 0 deletions helm-chart/eoapi/tests/ingress_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,65 @@ tests:
- equal:
path: spec.rules[0].http.paths[1].backend.service.name
value: doc-server-RELEASE-NAME

- it: "custom paths for multiple services with nginx controller"
set:
ingress.className: "nginx"
raster.enabled: true
raster.ingress.path: "/titiler"
stac.enabled: true
stac.ingress.path: "/api"
vector.enabled: true
vector.ingress.path: "/features"
multidim.enabled: false
browser.enabled: false
asserts:
- isKind:
of: Ingress
- equal:
path: spec.rules[0].http.paths[0].path
value: "/titiler(/|$)(.*)"
- equal:
path: spec.rules[0].http.paths[1].path
value: "/api(/|$)(.*)"
- equal:
path: spec.rules[0].http.paths[2].path
value: "/features(/|$)(.*)"
- equal:
path: spec.rules[0].http.paths[0].pathType
value: "ImplementationSpecific"
- equal:
path: spec.rules[0].http.paths[1].pathType
value: "ImplementationSpecific"
- equal:
path: spec.rules[0].http.paths[2].pathType
value: "ImplementationSpecific"
- equal:
path: metadata.annotations
value:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2

- it: "custom paths with traefik controller"
set:
ingress.className: "traefik"
raster.enabled: false
stac.enabled: true
stac.ingress.path: "/api"
vector.enabled: false
multidim.enabled: false
browser.enabled: false
asserts:
- isKind:
of: Ingress
- equal:
path: spec.rules[0].http.paths[0].path
value: "/api"
- equal:
path: spec.rules[0].http.paths[0].pathType
value: "Prefix"
- equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: NAMESPACE-strip-prefix-middleware-RELEASE-NAME@kubernetescrd
6 changes: 5 additions & 1 deletion helm-chart/eoapi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ raster:
enabled: true
ingress:
enabled: true # Control ingress specifically for raster service
path: "/raster" # Configurable path prefix for the raster service
autoscaling:
# NOTE: to have autoscaling working you'll need to install the `eoapi-support` chart
# see ../../../docs/autoscaling.md for more information
Expand Down Expand Up @@ -261,6 +262,7 @@ multidim:
enabled: false # disabled by default
ingress:
enabled: true # Control ingress specifically for multidim service
path: "/multidim" # Configurable path prefix for the multidim service
autoscaling:
# NOTE: to have autoscaling working you'll need to install the `eoapi-support` chart
# see ../../../docs/autoscaling.md for more information
Expand Down Expand Up @@ -332,6 +334,7 @@ stac:
enabled: true
ingress:
enabled: true # Control ingress specifically for stac service
path: "/stac" # Configurable path prefix for the stac service
autoscaling:
# NOTE: to have autoscaling working you'll need to install the `eoapi-support` chart
# see ../../../docs/autoscaling.md for more information
Expand Down Expand Up @@ -391,6 +394,7 @@ vector:
enabled: true
ingress:
enabled: true # Control ingress specifically for vector service
path: "/vector" # Configurable path prefix for the vector service
autoscaling:
# NOTE: to have autoscaling working you'll need to install the `eoapi-support` chart
# see ../../../docs/autoscaling.md for more information
Expand Down Expand Up @@ -473,4 +477,4 @@ docServer:
# prefer to set it in the command line
# helm upgrade --set previousVersion=$PREVIOUS_VERSION
# or in the CI/CD pipeline
previousVersion: ""
previousVersion: ""