Skip to content

lbipam: allow sharing IPs across services that select different pods - #45819

Merged
joestringer merged 1 commit into
cilium:mainfrom
lexfrei:feat/lbipam-sharing-permit-different-pods
Sep 10, 2026
Merged

joestringer merged 1 commit into
cilium:mainfrom
lexfrei:feat/lbipam-sharing-permit-different-pods

Conversation

@lexfrei

@lexfrei lexfrei commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Description of change

LB IPAM rejected services with externalTrafficPolicy: Local from sharing an IP unless they selected the same set of pods. This default is correct for users relying on Cilium's built-in BGP or L2 announcers, which are not L4 aware: announcing the shared IP from a node that lacks a backend for one of the services would drop traffic for that service.

Some deployments steer traffic with mechanisms outside Cilium's view — most notably an external L4-aware load balancer that uses each service's healthCheckNodePort to route only to nodes with a backend, or DaemonSets with matching node coverage so every node hosts every backend. For these the same-selector check is too strict.

This PR adds an opt-in annotation lbipam.cilium.io/sharing-permit-different-pods. When set to true on all services in a sharing group, LB IPAM relaxes the same-selector requirement. The opt-in is symmetric (every service in the group must opt in), and it only relaxes the same-selector branch — services without a selector (Endpoints-based) are still rejected because LB IPAM cannot read endpoints to determine which nodes host backends.

The annotation value is parsed via strconv.ParseBool. Unparseable values default to disabled and emit a warning so users can debug typos.

The need for this opt-in was discussed in the linked CFP, where the maintainer initially preferred a smarter compatibility check but acknowledged that for use cases involving an external L4-aware load balancer there is no reliable way to validate the setup automatically, leaving an explicit opt-in as the practical path.

AI disclosure

This PR was prepared with AIL:3. I personally reviewed each line of the submission prior to opening this PR.

Fixes: #38766

LB IPAM: introduce the lbipam.cilium.io/sharing-permit-different-pods annotation to allow sharing an IP between services with externalTrafficPolicy=Local that select different pods. The annotation must be set to "true" on all services in the sharing group and is intended for deployments that steer traffic outside Cilium's built-in announcers.

@maintainer-s-little-helper maintainer-s-little-helper Bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 7, 2026
@github-actions github-actions Bot added the kind/community-contribution This was a contribution made by a community member. label May 7, 2026
@lexfrei
lexfrei marked this pull request as ready for review May 7, 2026 00:46
@lexfrei
lexfrei requested review from a team as code owners May 7, 2026 00:46
@julianwiedmann julianwiedmann added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. area/loadbalancing Impacts load-balancing and Kubernetes service implementations feature/lb-ipam labels May 12, 2026
@maintainer-s-little-helper maintainer-s-little-helper Bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 12, 2026
@julianwiedmann julianwiedmann added the kind/enhancement This would improve or streamline existing functionality. label May 12, 2026

@dylandreimerink dylandreimerink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two small nits from me, looks good to me otherwise.

Comment thread operator/pkg/lbipam/service_store.go Resolved
Comment thread Documentation/network/lb-ipam.rst Resolved

@YutaroHayakawa YutaroHayakawa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sig-k8s-owned changes looks good to me.

@aanm aanm added dont-merge/bad-bot To prevent MLH from marking ready-to-merge. and removed dont-merge/bad-bot To prevent MLH from marking ready-to-merge. labels May 27, 2026
@pchaigno

pchaigno commented Jun 2, 2026

Copy link
Copy Markdown
Member

Switching to draft while Dylan's review is addressed.

@pchaigno
pchaigno marked this pull request as draft June 2, 2026 14:09
@lexfrei
lexfrei force-pushed the feat/lbipam-sharing-permit-different-pods branch from ec1cce1 to 6a0b83d Compare June 4, 2026 21:07
@lexfrei
lexfrei marked this pull request as ready for review June 4, 2026 21:08
@pchaigno
pchaigno requested a review from dylandreimerink June 4, 2026 21:11
@lexfrei

lexfrei commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Apologies for the long delay here — this one slipped through the cracks on my side.

Both of Dylan's nits are now addressed: the verbose in-code comment is trimmed to a one-liner pointing at the annotation, and the "both"→"all" wording is fixed in the docs and aligned in the commit message and PR description. The PR is out of draft again and ready for another look.

One note: the latest commit shows up as Unverified, which is expected here — I couldn't produce a valid GPG signature locally this time due to disk space constraints on my end, so the DCO Signed-off-by trailer is present but the GPG signature isn't.

@pchaigno

pchaigno commented Jun 8, 2026

Copy link
Copy Markdown
Member

/test

@pchaigno
pchaigno enabled auto-merge June 8, 2026 13:03
auto-merge was automatically disabled June 9, 2026 08:24

Head branch was pushed to by a user without write access

@lexfrei
lexfrei force-pushed the feat/lbipam-sharing-permit-different-pods branch from 6a0b83d to 4f6b7fc Compare June 9, 2026 08:24
@joestringer
joestringer marked this pull request as draft September 2, 2026 17:40
@joestringer

Copy link
Copy Markdown
Member

I've marked this PR as draft. When you have addressed the comments and workflow test results, bring the PR back to the attention of reviewers by scrolling to the bottom of the page and clicking the "Ready for Review" button. Thanks!

@lexfrei
lexfrei force-pushed the feat/lbipam-sharing-permit-different-pods branch 3 times, most recently from efc2caa to 1e1ad2f Compare September 2, 2026 20:35
@lexfrei

lexfrei commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main and applied the wording suggestions. Two more changes on top. The io.cilium/lb-ipam-sharing-permit-different-pods alias is gone: the io.cilium aliases only exist as legacy names for annotations that predate the lbipam.cilium.io prefix, a new annotation has nothing to alias. The upgrade-notes entry is gone too, it described no behaviour change.

Add an opt-in annotation lbipam.cilium.io/sharing-permit-different-pods
that, when set on all sharing services, lets LB IPAM share an IP between
services with externalTrafficPolicy=Local that select different sets of
pods. The annotation must be present on every service with the same
sharing key for the relaxed check to take effect.

The default same-selector requirement protects users from a misrouted
shared IP, since Cilium's built-in BGP and L2 announcers are not L4
aware. Some deployments steer traffic with mechanisms outside Cilium's
view (an L4-aware external load balancer using each service's
healthCheckNodePort, or DaemonSets with matching node coverage), and
for those the same-selector check is too strict.

Documentation explains the trade-off and warns that combining the
opt-in with Cilium's built-in announcers can drop traffic.

Fixes: cilium#38766
Signed-off-by: Aleksei Sviridkin <[email protected]>
@lexfrei
lexfrei force-pushed the feat/lbipam-sharing-permit-different-pods branch from 1e1ad2f to d1c53f7 Compare September 2, 2026 22:12
@ajmmm
ajmmm self-requested a review September 3, 2026 10:53

@ajmmm ajmmm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, the docs read a lot better to me!

/cc @hemanthmalla

@ajmmm

ajmmm commented Sep 3, 2026

Copy link
Copy Markdown
Member

/test

@joestringer joestringer added the ail:3 AI Created, Human Full Structure. Generated content with editing done by a human. label Sep 9, 2026
@maintainer-s-little-helper maintainer-s-little-helper Bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Sep 9, 2026
@joestringer joestringer added release-note/major This PR introduces major new functionality to Cilium. and removed release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels Sep 9, 2026
@joestringer

joestringer commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

How does this impact the threat model?

If we consider that an attacker has access to one namespace, could they disrupt services in other namespaces by adding these annotations onto Pods they control?

cc @cilium/sig-lb

@joestringer joestringer added dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. and removed ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Sep 9, 2026
@dylandreimerink

dylandreimerink commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

@joestringer

How does this impact the threat model?
If we consider that an attacker has access to one namespace, could they disrupt services in other namespaces by adding these annotations onto Pods they control?

I think we are good. This feature works on top of the normal IP sharing. To share an IP across namespaces, all services in a sharing group must explicitly permit the namespaces of the other services in the sharing group. You have to explicitly open yourself up to IP sharing, a bad actor can't just modify annotations and steal arbitrary IPs without also having control over the other service.

With regard to this feature, this part is important

This PR adds an opt-in annotation lbipam.cilium.io/sharing-permit-different-pods. When set to true on all services in a sharing group, LB IPAM relaxes the same-selector requirement. The opt-in is symmetric (every service in the group must opt in), and it only relaxes the same-selector branch

So all services in a sharing group have to opt-in to this feature as well, one service can't change the behavior on its own.

@joestringer

Copy link
Copy Markdown
Member

I see yep. Seems like this extends further the existing framework documented here, so falls under the same threat model. 👍

Then I think this is ready to merge. Thanks!

@joestringer joestringer removed the dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. label Sep 10, 2026
@maintainer-s-little-helper maintainer-s-little-helper Bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Sep 10, 2026
@joestringer
joestringer added this pull request to the merge queue Sep 10, 2026
Merged via the queue into cilium:main with commit d3ed6db Sep 10, 2026
82 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ail:3 AI Created, Human Full Structure. Generated content with editing done by a human. area/loadbalancing Impacts load-balancing and Kubernetes service implementations feature/lb-ipam kind/community-contribution This was a contribution made by a community member. kind/enhancement This would improve or streamline existing functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/major This PR introduces major new functionality to Cilium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CFP: Allow shared lb ipam ip on services selecting different pods

10 participants