Skip to content

feat: support merging www and apex routes if defined separately - #530

Draft
shreddedbacon wants to merge 1 commit into
mainfrom
merge-route-to-apex
Draft

shreddedbacon wants to merge 1 commit into
mainfrom
merge-route-to-apex

Conversation

@shreddedbacon

@shreddedbacon shreddedbacon commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Adds support for consolidating www and apex domains into one ingress object to reduce certificate and ingress object counts in a cluster.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Merging can discard route configuration and change an explicitly selected primary hostname.

2 open issues
What changed in this PR

This PR adds opt-in consolidation of separately defined apex and www routes into a single ingress, reducing ingress and certificate counts.

Changes:

  • Adds the ROUTE_MERGE_APEX feature flag and integrates merging into route generation.
  • Adds merge eligibility checks and preserves the first-listed hostname.
  • Adds unit tests, command-level tests, and expected ingress fixtures.
File Description
internal/​testdata/​node/​lagoon.yml Adds route pairs and alternative-name fixtures.
internal/​testdata/​node/​ingress-templates/​multidomain-merge-apex-routes/​www.example4.com.yaml Expected www ingress with existing aliases.
internal/​testdata/​node/​ingress-templates/​multidomain-merge-apex-routes/​www.example3.com.yaml Expected merged ingress with www listed first.
internal/​testdata/​node/​ingress-templates/​multidomain-merge-apex-routes/​example2.com.yaml Expected apex ingress with existing aliases.
internal/​testdata/​node/​ingress-templates/​multidomain-merge-apex-routes/​example.com.yaml Expected merged apex ingress with monitoring.
internal/​lagoon/​routes.go Implements route pairing and merge eligibility checks.
internal/​lagoon/​routes_test.go Tests merging, ordering, and selected exclusions.
internal/​generator/​ingress.go Applies merging when enabled.
internal/​generator/​generator.go Reads the merge feature flag.
internal/​generator/​buildvalues.go Stores the merge setting.
cmd/​template_ingress_test.go Adds merged-ingress rendering coverage.
cmd/​identify_ingress_test.go Adds route-identification coverage with merging enabled.

Review effort: Balanced

Comment thread internal/lagoon/routes.go
Comment on lines +528 to +537
if !canMergeWWWRoute(routes[apexIdx], routes[wwwIdx]) {
continue
}

// whichever domain appears earliest in the original list is retained as-is;
// the later one is folded into it as an alternativeName
keepIdx, dropIdx := apexIdx, wwwIdx
if wwwIdx < apexIdx {
keepIdx, dropIdx = wwwIdx, apexIdx
}
Comment thread internal/lagoon/routes.go
Comment on lines +539 to +540
routes[keepIdx].AlternativeNames = helpers.AppendIfMissing(routes[keepIdx].AlternativeNames, routes[dropIdx].Domain)
folded[routes[dropIdx].Domain] = true
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