host2regex: doesn't take in consideration `*`
converting host from Ingress/RouteGroup for Host predicate doesn't take into consideration that Ingress support wildcard hostnames (see https://kubernetes.io/docs/concepts/services-networking/ingress/#hostname-wildcards) and we produce invalid regex
This PR adds testcases to reproduce the error, requires fix before merging.
following ingress produce
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: simple
labels:
name: simple
spec:
rules:
- host: "*.example.org"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: simple
port:
number: 80
Error:
[APP]time="2024-11-01T12:43:46Z" level=error msg="kube_default__simple_redirect_app_default_0____example_org_____ [2]: error parsing regexp: missing argument to repetition operator: *
Test with
➜ ./bin/skipper -inline-routes 'r0: Host("*.mu.sa") -> inlineContent("hi from 0") -> <shunt>; r1: Host("ab.mu.sa") -> inlineContent("hi from 1") -> <shunt>;' -address=:8080
➜ curl -i -H "Host: ba.mu.sa" http://127.0.0.1:8080
HTTP/1.1 200 OK
Content-Length: 9
Content-Type: text/plain; charset=utf-8
Server: Skipper
Date: Tue, 03 Jun 2025 11:18:23 GMT
hi from 0%
➜ curl -i -H "Host: ab.mu.sa" http://127.0.0.1:8080
HTTP/1.1 200 OK
Content-Length: 9
Content-Type: text/plain; charset=utf-8
Server: Skipper
Date: Tue, 03 Jun 2025 11:18:28 GMT
hi from 1%
fixes https://github.com/zalando/skipper/issues/3297
maybe it's not a good idea to have this at all
See https://github.com/zalando/skipper/issues/3297#issuecomment-2454827352
@szuecs
A problem with the current implementation is that a request can flap between 2 or more routes
request to foo.example with
r: Host("*.example") -> <shunt>;
s: Host("foo.example") -> <shunt>;
Can this advance, e.g. with a feature toggle to support it? I would say potential conflicts can also be ruled user error and not skipper error.
What would be needed if you wanted to elevate the support? Weights? Warnings?