Skip to content

[CFP-39876]: Add namespace filtering to service sync and MCS API service exports#43385

Merged
squeed merged 2 commits intocilium:mainfrom
jimassa:topic/jimassa/cm-ns-sync-services
Feb 2, 2026
Merged

[CFP-39876]: Add namespace filtering to service sync and MCS API service exports#43385
squeed merged 2 commits intocilium:mainfrom
jimassa:topic/jimassa/cm-ns-sync-services

Conversation

@jimassa
Copy link
Copy Markdown
Contributor

@jimassa jimassa commented Dec 16, 2025

Description

Follow-up to #42905, continuing the implementation of CFP-74.

Adds namespace filtering to service sync and MCS-API ServiceExport sync. Services and ServiceExports are only synced to the kvstore when they belong to a "global" namespace.

By default all namespaces are global. Set --clustermesh-default-global-namespace=false to require explicit clustermesh.cilium.io/global="true" annotation.

Changes

operator/watchers/service_sync.go

  • Add namespace event watcher to re-sync services when namespace global status changes
  • Filter services based on namespace global status before syncing

pkg/clustermesh/mcsapi/serviceexportsync.go

  • Add namespace event watcher to re-sync ServiceExports when namespace global status changes
  • Filter ServiceExports based on namespace global status before syncing

Tests

  • operator/watchers/testdata/globalnamespace-services.txtar: Script test for service sync filtering (including dynamic namespace changes)
  • pkg/clustermesh/mcsapi/serviceexportsync_test.go: Unit test for ServiceExport sync filtering

Manual Testing on Kind Clusters

Tested on two kind clusters with ClusterMesh enabled and --clustermesh-default-global-namespace=false:

Setup

  • Two kind clusters using make kind-clustermesh and make kind-clustermesh-images
  • Cilium installed with ClusterMesh enabled, namespace filtering flag, and MCS API enabled

Service Namespace Filtering Results

Test Result
Created global service in default namespace (without namespace annotation) NOT synced to kvstore
Annotated namespace with clustermesh.cilium.io/global=true Service synced to kvstore
Created another global service Immediately synced to kvstore
Removed namespace annotation Services removed from kvstore

ServiceExport Namespace Filtering Results (MCS API)

Test Result
Created ServiceExport in default namespace (without namespace annotation) NOT synced to kvstore
Annotated namespace with clustermesh.cilium.io/global=true ServiceExport synced to kvstore
Removed namespace annotation ServiceExport removed from kvstore

Verification Commands Used

# Check services in kvstore
kubectl exec deploy/clustermesh-apiserver -c kvstoremesh \
    --context=kind-clustermesh1 --namespace=kube-system -- \
    clustermesh-apiserver shell kvstore/list cilium/state/services

# Check serviceexports in kvstore
kubectl exec deploy/clustermesh-apiserver -c kvstoremesh \
    --context=kind-clustermesh1 --namespace=kube-system -- \
    clustermesh-apiserver shell kvstore/list cilium/state/serviceexports

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.
  • 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.
  • Thanks for contributing!
Add global namespace filtering support to service sync and MCS API service exports for improved ClusterMesh scalability

@maintainer-s-little-helper
Copy link
Copy Markdown

Commit 6a96074 does not match "(?m)^Signed-off-by:".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Dec 16, 2025
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Dec 16, 2025
@maintainer-s-little-helper
Copy link
Copy Markdown

Commit 6a96074 does not match "(?m)^Signed-off-by:".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from 433c605 to b0d5524 Compare December 16, 2025 22:38
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Dec 16, 2025
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from b0d5524 to ec7ea5b Compare December 18, 2025 22:20
@maintainer-s-little-helper
Copy link
Copy Markdown

Commit ec7ea5b does not match "(?m)^Signed-off-by:".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Dec 18, 2025
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from ec7ea5b to f7228b6 Compare December 18, 2025 22:22
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Dec 18, 2025
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from f7228b6 to 78a01e0 Compare December 18, 2025 22:32
@maintainer-s-little-helper
Copy link
Copy Markdown

Commit d569d22 does not match "(?m)^Signed-off-by:".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Dec 19, 2025
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from d569d22 to cc6941f Compare December 19, 2025 18:00
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Dec 19, 2025
@jimassa jimassa marked this pull request as ready for review December 19, 2025 18:02
@jimassa jimassa requested review from a team as code owners December 19, 2025 18:02
@jimassa jimassa requested review from MrFreezeex and squeed December 19, 2025 18:02
@MrFreezeex MrFreezeex added area/clustermesh Relates to multi-cluster routing functionality in Cilium. release-note/misc This PR makes changes that have no direct user impact. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Dec 19, 2025
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.

Hi 👋, thanks for the PR, could you cleanup your git history so that it only includes the relevant commit, thanks!

Copy link
Copy Markdown
Contributor

@anubhabMajumdar anubhabMajumdar left a comment

Choose a reason for hiding this comment

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

Left comments for service_sync.go. Lot of the comments apply for serviceexportsync.go too.
Also, can you add new tests under testdata to cover the new scenarios?
Thanks!

@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from cc6941f to c507889 Compare December 19, 2025 22:20
@jimassa jimassa requested a review from a team as a code owner December 19, 2025 22:20
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from c507889 to f5155fc Compare December 19, 2025 22:25
@anubhabMajumdar
Copy link
Copy Markdown
Contributor

/ci-kpr

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.

Please apply the patch from the inline comment to fix the unreliable test. Looks good to me otherwise.

@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from 3f2c807 to e8c5d43 Compare January 22, 2026 10:10
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!

@giorio94
Copy link
Copy Markdown
Member

/test

@giorio94
Copy link
Copy Markdown
Member

@jimassa It looks like this PR picked a conflict, and will need to be rebased.

@giorio94 giorio94 added the dont-merge/needs-rebase This PR needs to be rebased because it has merge conflicts. label Jan 26, 2026
@giorio94 giorio94 disabled auto-merge January 26, 2026 11:17
Filter services synced to the kvstore based on namespace annotations.
By default all namespaces are global; set clustermesh-default-global-namespace=false
to require explicit clustermesh.cilium.io/global="true" annotation.

Signed-off-by: Jacques Massa <jac.massa0908@gmail.com>
Extend namespace filtering to MCS-API ServiceExport sync, using the
same global namespace logic as service sync. ServiceExports in non-global
namespaces are not synced to the kvstore.

Signed-off-by: Jacques Massa <jac.massa0908@gmail.com>
@jimassa jimassa force-pushed the topic/jimassa/cm-ns-sync-services branch from e8c5d43 to 8717cde Compare January 26, 2026 13:51
@giorio94 giorio94 removed the dont-merge/needs-rebase This PR needs to be rebased because it has merge conflicts. label Jan 26, 2026
@giorio94
Copy link
Copy Markdown
Member

/test

@giorio94
Copy link
Copy Markdown
Member

@cilium/operator Gentle ping 🙏

@anubhabMajumdar
Copy link
Copy Markdown
Contributor

/ci-l3-l4

@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 Jan 28, 2026
@squeed squeed enabled auto-merge February 2, 2026 11:38
@squeed squeed added this pull request to the merge queue Feb 2, 2026
Merged via the queue into cilium:main with commit d7aca94 Feb 2, 2026
75 of 76 checks passed
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. kind/community-contribution This was a contribution made by a community member. 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

None yet

Development

Successfully merging this pull request may close these issues.

6 participants