Skip to content

Support automatic fallback to endpoint routing for headless services when routingType=Service#8021

Merged
zirain merged 2 commits intoenvoyproxy:mainfrom
sudiptob2:feat/7849/support-fallback-endpoint-for-headless-service
Jan 28, 2026
Merged

Support automatic fallback to endpoint routing for headless services when routingType=Service#8021
zirain merged 2 commits intoenvoyproxy:mainfrom
sudiptob2:feat/7849/support-fallback-endpoint-for-headless-service

Conversation

@sudiptob2
Copy link
Copy Markdown
Member

What type of PR is this?
Attempted to implement automatically detect headless services and fall back to endpoint routing when routingType=Service is enabled

Which issue(s) this PR fixes:
Fixes #7849

Release Notes: No

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 22, 2026

Deploy Preview for cerulean-figolla-1f9435 canceled.

Name Link
🔨 Latest commit 8ef4f6b
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6976fe486cb59e0008707cbb

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.75%. Comparing base (424d039) to head (8ef4f6b).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8021      +/-   ##
==========================================
+ Coverage   73.70%   73.75%   +0.04%     
==========================================
  Files         237      237              
  Lines       35703    35704       +1     
==========================================
+ Hits        26316    26332      +16     
+ Misses       7529     7516      -13     
+ Partials     1858     1856       -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.

@sudiptob2 sudiptob2 force-pushed the feat/7849/support-fallback-endpoint-for-headless-service branch from 761e025 to c4d1436 Compare January 22, 2026 16:57
@sudiptob2 sudiptob2 marked this pull request as ready for review January 22, 2026 17:39
@sudiptob2 sudiptob2 requested a review from a team as a code owner January 22, 2026 17:39
if service.Spec.ClusterIP == "None" || service.Spec.ClusterIP == "" {
return true
}
if len(service.Spec.ClusterIPs) > 0 {
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.

is this needed ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This part is supposed to check for a single stack

   
	if service.Spec.ClusterIP == "None" || service.Spec.ClusterIP == "" {
		return true
	}

And this part is for dual stack

	if len(service.Spec.ClusterIPs) > 0 {
		for _, ip := range service.Spec.ClusterIPs {
			if ip != "None" && ip != "" {
				return false
			}
		}
		return true
	}

However, in practice, I am unsure if a case like THIS TESTCASE is even possible, where the service is dual-stack headless (ClusterIPs: []string{"None", "None"}) but ClusterIP is set. I guess not.

In that case, I guess we can remove the part where I am iterating over service.Spec.ClusterIPs list. Let me know your thoughts.

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.

can you cross check, if that test case is NA, we should just rm it and the logic to avoid designing around this in the future

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just checked; that testcase is not possible in practice. I tried to create the following service, and it's rejected by Kubernetes API server validation. Updated the code now

apiVersion: v1
kind: Service
metadata:
  name: headless-service
spec:
  clusterIP: None
  clusterIPs:
    - 10.96.0.100
    - fd00:10:96::100
  ipFamilies:
    - IPv4
    - IPv6
  ipFamilyPolicy: RequireDualStack   # add this
  selector:
    app: headless-backend
  ports:
    - port: 80

arkodg
arkodg previously approved these changes Jan 25, 2026
Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@arkodg arkodg added this to the v1.7.0-rc.1 Release milestone Jan 25, 2026
@arkodg arkodg requested review from a team January 25, 2026 20:06
@zirain zirain force-pushed the feat/7849/support-fallback-endpoint-for-headless-service branch from c4d1436 to eefe70c Compare January 26, 2026 00:21
zirain
zirain previously approved these changes Jan 26, 2026
@sudiptob2 sudiptob2 dismissed stale reviews from zirain and arkodg via 5987e1b January 26, 2026 05:08
@sudiptob2 sudiptob2 force-pushed the feat/7849/support-fallback-endpoint-for-headless-service branch from eefe70c to 5987e1b Compare January 26, 2026 05:08
…ing type is set to Service

Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>
Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>
@zirain zirain force-pushed the feat/7849/support-fallback-endpoint-for-headless-service branch from 5987e1b to 8ef4f6b Compare January 26, 2026 05:40
@zirain zirain merged commit 32d1c74 into envoyproxy:main Jan 28, 2026
36 checks passed
SadmiB pushed a commit to SadmiB/gateway that referenced this pull request Jan 30, 2026
…when routingType=Service (envoyproxy#8021)

* Implement fallback to endpoint routing on headless services when routing type is set to Service

Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>

* improve headless service detection logic

Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>

---------

Signed-off-by: Sudipto Baral <sudiptobaral.me@gmail.com>
Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
@sudiptob2 sudiptob2 deleted the feat/7849/support-fallback-endpoint-for-headless-service branch March 1, 2026 23:26
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.

Support fallback to endpoint routing on headless services when routingType is set to Service

3 participants