Skip to content

wildcard hostnames produce invalid regex for Host predicate #3297

Open
@MustafaSaber

Description

@MustafaSaber

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 #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]+)?)$

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions