Skip to content

Commit e6e0fed

Browse files
Refactor: Implement unified ingress configuration for nginx and traefik, streamline values.yaml, and update related documentation and tests
1 parent ee41f4b commit e6e0fed

File tree

10 files changed

+263
-398
lines changed

10 files changed

+263
-398
lines changed

docs/unified-ingress.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Unified Ingress Configuration
2+
3+
This document describes the unified ingress approach implemented in the eoAPI Helm chart.
4+
5+
## Overview
6+
7+
eoAPI now uses a consolidated, controller-agnostic ingress configuration. This approach:
8+
9+
- Eliminates code duplication between different ingress controller implementations
10+
- Provides consistent behavior across controllers
11+
- Simplifies testing and maintainability
12+
- Removes artificial restrictions on using certain ingress controllers in specific environments
13+
- Makes it easier to add support for additional ingress controllers in the future
14+
15+
## Configuration
16+
17+
The ingress configuration has been streamlined and generalized in the `values.yaml` file:
18+
19+
```yaml
20+
ingress:
21+
# Unified ingress configuration for both nginx and traefik
22+
enabled: true
23+
# ingressClassName: "nginx" or "traefik"
24+
className: "nginx"
25+
# Path configuration
26+
pathType: "Prefix" # Can be "Prefix" or "ImplementationSpecific" based on controller
27+
pathSuffix: "" # Add a suffix to service paths (e.g. "(/|$)(.*)" for nginx regex)
28+
rootPath: "" # Root path for doc server
29+
# Host configuration
30+
host: ""
31+
# Custom annotations to add to the ingress
32+
annotations: {}
33+
# TLS configuration
34+
tls:
35+
enabled: false
36+
secretName: eoapi-tls
37+
certManager: false
38+
certManagerIssuer: letsencrypt-prod
39+
certManagerEmail: ""
40+
```
41+
42+
## Controller-Specific Configurations
43+
44+
### NGINX Ingress Controller
45+
46+
For NGINX, use the following configuration:
47+
48+
```yaml
49+
ingress:
50+
enabled: true
51+
className: "nginx"
52+
pathType: "ImplementationSpecific"
53+
pathSuffix: "(/|$)(.*)" # Required for NGINX path rewriting
54+
annotations:
55+
nginx.ingress.kubernetes.io/use-regex: "true"
56+
nginx.ingress.kubernetes.io/rewrite-target: /$2
57+
nginx.ingress.kubernetes.io/enable-cors: "true"
58+
nginx.ingress.kubernetes.io/enable-access-log: "true"
59+
```
60+
61+
### Traefik Ingress Controller
62+
63+
For Traefik, use the following configuration:
64+
65+
```yaml
66+
ingress:
67+
enabled: true
68+
className: "traefik"
69+
pathType: "Prefix"
70+
annotations:
71+
traefik.ingress.kubernetes.io/router.entrypoints: web
72+
traefik.ingress.kubernetes.io/router.pathtransform.regex: "^/([^/]+)(.*)"
73+
traefik.ingress.kubernetes.io/router.pathtransform.replacement: "/$1$2"
74+
```
75+
76+
## Migration
77+
78+
If you're migrating from a previous version, follow these guidelines:
79+
80+
1. Update your values to use the new unified configuration
81+
2. Ensure your ingress controller-specific annotations are set correctly
82+
3. Set the appropriate `pathType` and `pathSuffix` for your controller
83+
4. Test the configuration before deploying to production
84+
85+
## Note for Traefik Users
86+
87+
Traefik is now fully supported in all environments, including production. The previous restriction limiting Traefik to testing environments has been removed.
88+
89+
## Document Server
90+
91+
The document server implementation has also been unified. It now works with both NGINX and Traefik controllers using the same configuration.

helm-chart/eoapi/templates/_helpers.tpl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,3 @@ validate:
397397
{{- end -}}
398398
399399
{{- end -}}
400-
401-
{{/*
402-
validate:
403-
that you can only use traefik as ingress when `testing=true`
404-
*/}}
405-
{{- define "eoapi.validateTraefik" -}}
406-
{{- if and (not .Values.testing) (eq .Values.ingress.className "traefik") $ -}}
407-
{{- fail "you cannot use traefik yet outside of testing" -}}
408-
{{- end -}}
409-
410-
{{- end -}}

helm-chart/eoapi/templates/services/nginx-doc-server.yaml renamed to helm-chart/eoapi/templates/services/doc-server.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{{- if (and (.Values.ingress.className) (eq .Values.ingress.className "nginx") (not .Values.testing) (.Values.docServer.enabled))}}
1+
{{- if (and (not .Values.testing) (.Values.docServer.enabled))}}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:
5-
name: nginx-root-html-{{ .Release.Name }}
5+
name: doc-server-html-{{ .Release.Name }}
66
data:
77
index.html: |
88
<html>
@@ -11,7 +11,7 @@ data:
1111
</head>
1212
<body>
1313
<h2>This is the root path /</h2>
14-
<p>Your service configuration is using ingress-nginx with path rewrites. So use these paths for each service:</p>
14+
<p>Your service configuration is using path rewrites. So use these paths for each service:</p>
1515
<ul>
1616
<li><a href="/raster" target="_blank" rel="noopener noreferrer">/raster</a></li>
1717
<li><a href="/vector" target="_blank" rel="noopener noreferrer">/vector</a></li>
@@ -48,7 +48,7 @@ spec:
4848
volumes:
4949
- name: doc-html-{{ .Release.Name }}
5050
configMap:
51-
name: nginx-root-html-{{ .Release.Name }}
51+
name: doc-server-html-{{ .Release.Name }}
5252
{{- if .Values.docServer.settings }}
5353
{{- with .Values.docServer.settings.affinity }}
5454
affinity:

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

Lines changed: 0 additions & 105 deletions
This file was deleted.

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

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)