Skip to content

Sort wildcard domain ingress routes after non-wildcard routes#287

Open
joelcox22 wants to merge 6 commits intoSTRRL:masterfrom
joelcox22:master
Open

Sort wildcard domain ingress routes after non-wildcard routes#287
joelcox22 wants to merge 6 commits intoSTRRL:masterfrom
joelcox22:master

Conversation

@joelcox22
Copy link
Copy Markdown

I had a use-case where I wanted an ingress rule using a wildcard domain to act as a fallback when a more explicit rule did not exist, however with the sort logic of shortest hostnames first, the wildcard domain name was always taking priority even when a more specific domain name without a wildcard existed in a separate ingress route.

This change makes wildcard domains (e.g. *.example.com) be sorted after, and therefore take lower priority than non-wildcard domains (test.example.com), which seems to be a more sensible default behaviour to me.

If you'd like to test this, you can use the following helm values for now:

cloudflare-tunnel-ingress-controller:
  image:
    repository: ghcr.io/joelcox22/cloudflare-tunnel-ingress-controller
    tag: master-df3c2fb-amd64

Then deploy an ingress route with a wildcard, and you will see it's sorted in cloudflare connector application routes below the non-wildcard routes, where without this change, it ended up at the top of the list due to the hostname being shorter than the other routes that had more explicit domain names.


Note: these code changes and tests are generated by AI, but have been reviewed and tested by a human 😄

Copilot AI and others added 6 commits March 5, 2026 09:09
… as fallbacks

Co-authored-by: joelcox22 <1089216+joelcox22@users.noreply.github.com>
Co-authored-by: joelcox22 <1089216+joelcox22@users.noreply.github.com>
Co-authored-by: joelcox22 <1089216+joelcox22@users.noreply.github.com>
Rename `compareIngressRules` to `sortIngressRules` and add single-char subdomain test case
@joelcox22
Copy link
Copy Markdown
Author

Updated sample values.yaml which can be used for testing this change with latest changes from this repo:

cloudflare-tunnel-ingress-controller:
  image:
    repository: ghcr.io/joelcox22/cloudflare-tunnel-ingress-controller
    tag: master-43cf4dd-amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants