Add shared library for writing resources across clusters#618
Open
scotwells wants to merge 1 commit into
Open
Conversation
Promotes the MappedNamespaceResourceStrategy pattern from network-services-operator into a shared platform library so any service can write resources to a downstream cluster without duplicating the namespace-mapping and ownership-tracking logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
privateip
approved these changes
May 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changing
Adds a new
pkg/downstreamclientpackage that centralises the cross-cluster resource management pattern currently duplicated across services.Why it matters
Two services already implement this pattern independently:
MappedNamespaceResourceStrategyininternal/downstreamclient/to write network resources into downstream clusters, mapping upstream project namespaces tons-<uid>namespaces on the targetWorkloadDeploymentobjects to the Karmada control plane and projectInstanceobjects back to management cluster namespacesWithout a shared library each new service that does cross-cluster writes copies the same code, with the risk of the namespace-mapping convention, anchor ConfigMap pattern, and upstream-owner labels drifting out of sync.
What's included
The
pkg/downstreamclientpackage (moved and exported from NSO's internal package) handles:ns-<uid>on the downstream clustermeta.datumapis.com/*labels so resources can always be traced back to their origin cluster, namespace, group, and kindTypedEnqueueRequestsForUpstreamOwner— generic controller-runtime handler that re-enqueues the upstream owner when a downstream resource changesWhat's not changing
No existing behaviour changes. NSO's internal copy is unaffected until it chooses to migrate to this package. This PR is purely additive.
Consumers
Once tagged, the following services will import this package:
go.datum.net/network-services-operator— migrate away frominternal/downstreamclient/go.datum.net/compute— useMappedNamespaceResourceStrategyin the Karmada federation path