Skip to content

[CFP-39876]: Implement global namespace support for CEP, identities and slices#42905

Merged
MrFreezeex merged 4 commits intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/cm-ns-sync
Dec 19, 2025
Merged

[CFP-39876]: Implement global namespace support for CEP, identities and slices#42905
MrFreezeex merged 4 commits intocilium:mainfrom
anubhabMajumdar:topic/anmajumdar/cm-ns-sync

Conversation

@anubhabMajumdar
Copy link
Copy Markdown
Contributor

@anubhabMajumdar anubhabMajumdar commented Nov 20, 2025

Description

This PR is laying the foundation for cilium/design-cfps#74 .

Adds namespace-level filtering for a subset of ClusterMesh resource synchronization using the clustermesh.cilium.io/global annotation, allowing administrators to control which namespaces export resources to the kvstore. Resources handled in this PR are CiliumEndpoints, CiliumIdentities and CiliumEndpointSlices.

Key changes

  • New clustermesh.cilium.io/global annotation to mark namespaces for export
  • Namespace manager tracks global status with --clustermesh-default-global-namespace flag (default: true)
  • Resource synchronizers filter resource events based on namespace global status
  • Automatic cleanup when resources move out of global namespaces
  • Namespace event handling triggers resynchronization of affected resources (ex: annotating namespace as global or local)

Behavior

  • All namespaces are global by default (backward compatible), i.e., --clustermesh-default-global-namespace=true by default
  • Opt-out: add clustermesh.cilium.io/global: "false" to namespace
  • When flag is false, namespaces must opt-in with annotation set to "true"
  • Resources automatically removed from kvstore when namespace becomes non-global
  • The flag is currently hidden from users as feature is incomplete

Testing Done

  • Setup two kind clusters using make kind-clustermesh
  • Build and install clustermesh with enable-default-global-namespace=false
  • Exec into kvstoremesh container k exec -it deploy/clustermesh-apiserver -c kvstoremesh --context=kind-clustermesh2 --namespace=kube-system -- clustermesh-apiserver shell
  • Check clustermesh kvstore using kvstore/list --keys-only --output=string (no identities or endpoints)
  • Annotate default namespace in both cluster
  • Check clustermesh kvstore using kvstore/list --keys-only --output=string (identities and endpoints present now)
  • Created/Deleted deployments to check kvstore is updated accordingly
  • Deployed Hubble to make sure during cross cluster communication, flow logs are accurate (with annotation, I see pod -> pod flows, but w/o annotation pod->IP flows)
  • New unit tests
  • New E2E tests using the Hive script

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

Fixes: #issue-number

<!-- Enter the release note text here if needed or remove this section! -->

@anubhabMajumdar anubhabMajumdar requested review from a team as code owners November 20, 2025 23:39
@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 Nov 20, 2025
@giorio94 giorio94 self-requested a review November 21, 2025 17:54
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Fixing the lint issues.

@youngnick
Copy link
Copy Markdown
Contributor

Still some lint issues remaining, you'll need to fix both the goimports and slog fields not being constant errors.

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/cm-ns-sync branch from ec54724 to 537a310 Compare November 24, 2025 21:20
Copy link
Copy Markdown
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks! 🙏 The approach seems to make sense to me overall, I left an initial review with some comment inline.

Also I think it would makes sense to split a bit more your commits, the namespace helpers seems to be an obvious candidate for this at least 🤔,

Copy link
Copy Markdown
Member

@giorio94 giorio94 left a comment

Choose a reason for hiding this comment

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

Thanks @anubhabMajumdar for iterating on this!

I've started reviewing the new approach, and left a few initial high level comments. Overall it looks better to me compared to the previous ones, but I still have a few reservations detailed inline.

A few more general comments:

  • Make sure that the commits pass the basic linting checks before marking a PR ready for review, as there are currently multiple failures (and also compilation errors in tests)
  • Make sure that the implementation is actually working; the clustermesh-apiserver is currently crashing due to unmet hive dependencies;
  • The clustermesh-apiserver package makes already use of script tests. Please introduce one or more new script test file to validate the correct functioning of the new namespace filtering E2E, to increase confidence in the correctness of the implementation and prevent future regressions.
  • The current implementation is entirely included in a single large commit, which makes the review process complex. Please split it into multiple commits, each complemented by a commit message to detail the rationale behind each set of changes. See the amazing split done by @jshr-w in #38388 as an example.

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/cm-ns-sync branch from f0f962c to 2dfc21c Compare December 2, 2025 21:06
@anubhabMajumdar anubhabMajumdar requested review from a team as code owners December 2, 2025 21:06
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Fixing the lint issues and will add one more commit for the script tests.

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/cm-ns-sync branch 5 times, most recently from d5a6db0 to 5d6176c Compare December 3, 2025 03:34
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

@MrFreezeex @giorio94

Thanks for your reviews. I have:

  • addressed all comments
  • split changes into granular commits
  • added new e2e tests for cluster mesh

Cheers!

Copy link
Copy Markdown
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

Helm structure-wise this looks okay to me. I do have some concerns regarding the naming and enabling this by default

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/cm-ns-sync branch from 5d6176c to 5bd00d4 Compare December 3, 2025 17:46
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

Fixed one test issues. Rest seems to stem from the configurations to the helm chart, but that was removed.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

Had to rebase to fix the last commit length. Will restart the tests again.

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

Copy link
Copy Markdown
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks the PR seems to be in a great shape overall, I left some minor question/comments about a few things in the code that I spotted

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

@giorio94 @MrFreezeex
Addressed your comments, let me know if this looks good. Thanks :-)

Copy link
Copy Markdown
Member

@giorio94 giorio94 left a comment

Choose a reason for hiding this comment

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

Addressed your comments, let me know if this looks good. Thanks :-)

There's still one bug introduced in the last iteration, but looks good to me otherwise.

…onizer

Add namespace filtering to synchronizer to only sync resources from
global namespaces.

- Add Namespacer interface and implementations for namespace extraction
- Integrate namespace manager into synchronizer to filter events
- Watch namespace changes and resynchronize affected resources
- Mark CiliumIdentity, CiliumEndpoint, and CiliumEndpointSlice as namespaced

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
Add integration tests for global namespace filtering behavior.

- Add globalnamespace.txtar to test clustermesh-default-global-namespace=false
- Update existing tests with namespace resources
- Test namespace annotation changes and deletions

Signed-off-by: Anubhab Majumdar <anmajumdar@microsoft.com>
@anubhabMajumdar anubhabMajumdar force-pushed the topic/anmajumdar/cm-ns-sync branch from b117415 to b9a43dc Compare December 17, 2025 18:37
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Addressed your comments, let me know if this looks good. Thanks :-)

There's still one bug introduced in the last iteration, but looks good to me otherwise.

Thanks for reviewing this multiple times!

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/test

@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

/ci-delegated-ipam

Copy link
Copy Markdown
Member

@giorio94 giorio94 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!

Copy link
Copy Markdown
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks!

@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 Dec 19, 2025
@MrFreezeex MrFreezeex added this pull request to the merge queue Dec 19, 2025
@anubhabMajumdar
Copy link
Copy Markdown
Contributor Author

Thanks @MrFreezeex @giorio94 @youngnick for repeated reviews. Cheers!

Merged via the queue into cilium:main with commit b5d3df3 Dec 19, 2025
78 checks passed
@anubhabMajumdar anubhabMajumdar deleted the topic/anmajumdar/cm-ns-sync branch December 19, 2025 17:44
@cilium-release-bot cilium-release-bot bot moved this to Released in cilium v1.19.0 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/clustermesh Relates to multi-cluster routing functionality in Cilium. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

No open projects
Status: Released

Development

Successfully merging this pull request may close these issues.

5 participants