Skip to content

Commit

Permalink
salt: Add dedicated Ingress for MetalK8s docs
Browse files Browse the repository at this point in the history
Adding a `rewrite-target` annotation is needed when the base path is not
/, because NGINX does not know where to find the documentation static
files.

We now always expose MetalK8s docs behind /docs, optionally appending
the configured base path for MetalK8s UI (e.g. /docs/platform).
This will avoid strange conflicts with the behaviour of the current
Ingress when running MetalK8s at a non-root path, because mixing regular
expressions and exact matches does not play well with ingress-nginx.

See: #3254
See: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#use-regex
  • Loading branch information
gdemonet committed Apr 20, 2021
1 parent 2f50e1f commit 2feba68
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions salt/metalk8s/addons/ui/deployed/ingress.sls
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,30 @@ spec:
serviceName: metalk8s-ui
servicePort: 80
{% endfor %}
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx-control-plane
nginx.ingress.kubernetes.io/backend-protocol: HTTP
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: '/docs/$2'
labels:
app: metalk8s-docs
app.kubernetes.io/managed-by: salt
app.kubernetes.io/name: metalk8s-docs
app.kubernetes.io/part-of: metalk8s
heritage: metalk8s
name: metalk8s-docs
namespace: metalk8s-ui
spec:
rules:
- http:
paths:
- backend:
service:
name: metalk8s-ui
port:
number: 80
path: /docs/{{ stripped_base_path }}(/|$)(.*)

0 comments on commit 2feba68

Please sign in to comment.