Skip to content

feat: introduce EndpointHostname in BTP to set hostname field in Endpoint#8606

Open
zhuoyang wants to merge 19 commits into
envoyproxy:mainfrom
zhuoyang:implement-backend-service
Open

feat: introduce EndpointHostname in BTP to set hostname field in Endpoint#8606
zhuoyang wants to merge 19 commits into
envoyproxy:mainfrom
zhuoyang:implement-backend-service

Conversation

@zhuoyang

@zhuoyang zhuoyang commented Mar 27, 2026

Copy link
Copy Markdown

What type of PR is this?

Introduce EndpointHostname in BTP, to set hostname field in Endpoint

What this PR does / why we need it:
Currently HTTPURLRewriteFilter hostname.type: Backend doesn't work for backend pointing to k8s service, this PR will introduce the functionality to add k8s service FQDN to endpoint's hostname field.

Which issue(s) this PR fixes:

Fixes #7984

Release Notes: Yes

@zhuoyang
zhuoyang requested a review from a team as a code owner March 27, 2026 07:55
@netlify

netlify Bot commented Mar 27, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 5593590
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a4ca9914e65720008704806
😎 Deploy Preview https://deploy-preview-8606--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

…vice backend

Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
@zhuoyang
zhuoyang force-pushed the implement-backend-service branch from 841aaa6 to 806e05f Compare March 27, 2026 07:56
@zhuoyang

Copy link
Copy Markdown
Author

@guydc can you please take a look at this PR?

@arkodg
arkodg requested a review from guydc March 31, 2026 15:21
@arkodg arkodg added this to the v1.8.0-rc.1 Release milestone Mar 31, 2026
zhuoyang and others added 2 commits April 2, 2026 10:06
Signed-off-by: zhuoyang <zhuoyang98@gmail.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
@zhuoyang
zhuoyang force-pushed the implement-backend-service branch from f43fb70 to 6cb6abc Compare April 2, 2026 16:44
@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.38%. Comparing base (c7e21fa) to head (d85af66).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/gatewayapi/route.go 94.28% 1 Missing and 1 partial ⚠️
internal/gatewayapi/runner/runner.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8606      +/-   ##
==========================================
+ Coverage   74.33%   74.38%   +0.05%     
==========================================
  Files         244      244              
  Lines       38774    38808      +34     
==========================================
+ Hits        28823    28868      +45     
+ Misses       7953     7944       -9     
+ Partials     1998     1996       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

zhuoyang added 2 commits April 3, 2026 01:11
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
@zhuoyang

zhuoyang commented Apr 3, 2026

Copy link
Copy Markdown
Author

/retest

@zhuoyang

zhuoyang commented Apr 6, 2026

Copy link
Copy Markdown
Author

can someone approve my test run again?

@zhuoyang

zhuoyang commented Apr 7, 2026

Copy link
Copy Markdown
Author

i think the test is okay now, just some flaky e2e test (?)

@guydc

guydc commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Hi @zhuoyang ! Thanks for picking this up.
My main comments are:

  • There's a possible behavior change hidden here. I'm concerned that this hostname would now be propagated into active healthchecks if no explicit HC hostname override is configured. I'm not sure that the URL rewrite filter for regular traffic justifies an implicit change for HCs as well. In the Backend resource, users essentially opt-in to use a specific hostname for that backend, here it becomes implicit. Maybe we need some knob to control that. cc @envoyproxy/gateway-maintainers .
  • Prefer to see the hostname being built in the same codepath where it's being built for backends, meaning NewDestEndpoint rather than post endpoint creation.
  • Prefer to avoid reliance on resource metadata to built the service's FQDN. Metadata should not be used, ideally, as input to translation.
  • Prefer to avoid the EG restart mid-test. Can't we just rely on a default cluster.local domain here? Alternatively, set a. default value in the e2e test EG config?

@zhuoyang

Copy link
Copy Markdown
Author

Thanks for the feedback @guydc!

Maybe we need some knob to control that.

Since this is more of a HTTPRoute/Envoy Cluster level change rather than rule level change, maybe we should expose this under a different settings? Currently the hostname will be added to the endpoint if one of the rule has hostname.type set to Backend

Prefer to see the hostname being built in the same codepath where it's being built for backends, meaning NewDestEndpoint rather than post endpoint creation.

If we were to use NewDestEndpoint to build the hostname, we would need to add a new parameter in processServiceDestinationSetting and getIREndpointsFromEndpointSlices which will introduce changes in few other places, is that acceptable?

@guydc

guydc commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Since this is more of a HTTPRoute/Envoy Cluster level change rather than rule level change, maybe we should expose this under a different settings? Currently the hostname will be added to the endpoint if one of the rule has hostname.type set to Backend

Good point. Since the scope of the change is indeed wider than just traffic routed through, maybe this warrants a knob in in BTP that determine the "hostname" value:

  • default (backwards-compatible): No hostname
  • K8s Service name
  • Static value provided by user
    Need some other maintainers to chime in here. Will need to update docs to reflect the existence of this default and its impact on various features.

If we were to use NewDestEndpoint to build the hostname, we would need to add a new parameter in processServiceDestinationSetting and getIREndpointsFromEndpointSlices which will introduce changes in few other places, is that acceptable?

Maybe we can add a flag to IR like "useHostname", always true for backend with hostname, only true for service in some cases (maybe relates to previous point). XDS would only consume the hostname in some cases.

@zhuoyang

Copy link
Copy Markdown
Author

alternatively, I think we could just not utilize auto_host_rewrite for this case, and just rewrite the host manually
this would introduce less change and side effect while retaining the same behavior

@guydc

guydc commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

alternatively, I think we could just not utilize auto_host_rewrite for this case, and just rewrite the host manually
this would introduce less change and side effect while retaining the same behavior

Would that work in case there are multiple backendrefs to different services? In that case, only the final endpoint selected by the cluster would hold the correct hostname.

@zhuoyang

Copy link
Copy Markdown
Author

Would that work in case there are multiple backendrefs to different services?

I didn't think of this case, yeah I don't think it would work.

Comment thread internal/gatewayapi/route.go Outdated
}

if usesBackendHostRewrite(httpFiltersContext.URLRewrite) {
t.applyServiceBackendHostnames(allDs)

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.

Should this stay scoped to route rewrite instead of mutating DestinationEndpoint.Hostname?

@arkodg arkodg modified the milestones: v1.8.0-rc.1 Release, Backlog Apr 30, 2026
zhuoyang added 5 commits May 8, 2026 13:47
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
@zhuoyang
zhuoyang force-pushed the implement-backend-service branch from 51ffcc2 to 648c036 Compare May 8, 2026 08:51
@zhuoyang zhuoyang changed the title feat: support HTTPURLRewriteFilter hostname.type: Backend for k8s service backend feat: introduce EndpointHostname in BTP to set hostname field in Endpoint May 8, 2026
zhuoyang added 2 commits May 8, 2026 17:16
The Service GVK fallback and its associated tests are unrelated to the
endpointHostname BTP feature introduced in this PR.

Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
Signed-off-by: Teo Zhuo Yang <zteo@moneylion.com>
@zhuoyang

zhuoyang commented May 8, 2026

Copy link
Copy Markdown
Author

@guydc @jukie I've made changes to the PR to introduce the knob in BTP, let me know what you folks think.
I've not opted for adding the flag in IR, because it seems like it will introduce more changes.

@zhuoyang

zhuoyang commented Jun 2, 2026

Copy link
Copy Markdown
Author

gentle bump on this

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Jul 2, 2026
@github-actions github-actions Bot closed this Jul 14, 2026
@zhuoyang

Copy link
Copy Markdown
Author

@guydc @jukie can we reopen this?

@arkodg arkodg reopened this Jul 20, 2026
// If unset, no hostname is attached to Kubernetes Service endpoints.
//
// +optional
EndpointHostname *BackendEndpointHostname `json:"endpointHostname,omitempty"`

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.

doesnt the HTTPRouteFilter or Backend resource solve this use case

@github-actions github-actions Bot removed the stale label Jul 20, 2026
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.

HTTPURLRewriteFilter hostname type: Backend does not rewrite host name to Kubernetes DNS (auto_host_rewrite ineffective for K8s Services)

4 participants