Skip to content

Commit d4b5309

Browse files
Add Traefik middleware for path rewriting and update ingress annotations
1 parent d6abec2 commit d4b5309

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/helm-tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ jobs:
194194
run: |
195195
kubectl get svc --all-namespaces
196196
kubectl get ingress --all-namespaces -o jsonpath='{range .items[0]}kubectl describe ingress {.metadata.name} -n {.metadata.namespace}{end}' | sh
197-
kubectl get middleware.traefik.io --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' --no-headers | while read -r namespace name; do kubectl describe middleware.traefik.io "$name" -n "$namespace"; done
198197
199198
PUBLICIP='http://'$(kubectl -n kube-system get svc traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
200199
export VECTOR_ENDPOINT=$PUBLICIP/vector
@@ -207,10 +206,12 @@ jobs:
207206
echo $RASTER_ENDPOINT
208207
echo '#################################'
209208
210-
pytest .github/workflows/tests/test_vector.py || kubectl logs svc/vector
211-
pytest .github/workflows/tests/test_stac.py || kubectl logs svc/stac
209+
# Run tests with proper failure propagation
210+
set -e # Make sure any command failure causes the script to exit with error
211+
pytest .github/workflows/tests/test_vector.py || { kubectl logs svc/vector; exit 1; }
212+
pytest .github/workflows/tests/test_stac.py || { kubectl logs svc/stac; exit 1; }
212213
# TODO: fix raster tests
213-
#pytest .github/workflows/tests/test_raster.py || kubectl logs svc/raster
214+
#pytest .github/workflows/tests/test_raster.py || { kubectl logs svc/raster; exit 1; }
214215
215216
- name: error if tests failed
216217
if: steps.testrunner.outcome == 'failure'

helm-chart/eoapi/templates/services/ingress.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ metadata:
1212
labels:
1313
app: sharedingress
1414
annotations:
15+
{{- if eq .Values.ingress.className "traefik" }}
16+
traefik.ingress.kubernetes.io/router.entrypoints: web
17+
traefik.ingress.kubernetes.io/router.middlewares: path-rewrite-middleware-{{ $.Release.Name }}@kubernetescrd
18+
{{- end }}
1519
{{- if .Values.ingress.annotations }}
1620
{{ toYaml .Values.ingress.annotations | indent 4 }}
1721
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if and .Values.ingress.enabled (eq .Values.ingress.className "traefik") }}
2+
apiVersion: traefik.io/v1alpha1
3+
kind: Middleware
4+
metadata:
5+
name: path-rewrite-middleware-{{ $.Release.Name }}
6+
namespace: {{ $.Release.Namespace }}
7+
spec:
8+
replacePathRegex:
9+
regex: "^/(raster|vector|stac|multidim)(/|$)(.*)"
10+
replacement: "$1/$3"
11+
{{- end }}

helm-chart/eoapi/test-k3s-unittest-values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ ingress:
66
pathType: "Prefix"
77
annotations:
88
traefik.ingress.kubernetes.io/router.entrypoints: web
9-
traefik.ingress.kubernetes.io/router.pathtransform.regex: "^/([^/]+)(.*)"
10-
traefik.ingress.kubernetes.io/router.pathtransform.replacement: "/$1$2"
119
pgstacBootstrap:
1210
enabled: true
1311
settings:

0 commit comments

Comments
 (0)