zalando / skipper

An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress
https://opensource.zalando.com/skipper/
Other
3.12k stars 351 forks source link

wildcard hostnames produce invalid regex for `Host` predicate #3297

Open MustafaSaber opened 3 weeks ago

MustafaSaber commented 3 weeks ago

Describe the bug 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

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: *

To Reproduce

create ingress with wildcard hostname

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

Reproducer PR https://github.com/zalando/skipper/pull/3296

Expected behavior

Valid regex generated and routingTable updated with the new entries

Observed behavior

Not valid regex is created and ingress routes are ignored.

for this ingress ^(*[.]example[.]org[.]?(:[0-9]+)?)$

MustafaSaber commented 2 weeks ago

This can cause concerns about operational safety so we can also just