Skip to content

Introduce optional DefaultNamespaceConfiguration to WorkloadNetworkConfiguration - #61

Open
ihgann wants to merge 2 commits into
vmware-tanzu:masterfrom
ihgann:topic/ig010188/vpc-extended-fields-wlnc-v2
Open

Introduce optional DefaultNamespaceConfiguration to WorkloadNetworkConfiguration#61
ihgann wants to merge 2 commits into
vmware-tanzu:masterfrom
ihgann:topic/ig010188/vpc-extended-fields-wlnc-v2

Conversation

@ihgann

@ihgann ihgann commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This change introduces an addition to the WorkloadNetworkConfiguration CR to add optional DefaultNamespaceConfiguration in the case of a VPC environment.

This is to retain backwards-compatibility in the Supervisor where defaultPrivateCIDRs may be overwritten for new namespaces, disparate from existing configurations.

The logic is as such:

  • The SystemConfiguration directly influences the system NamespaceNetworkConfiguration that gets constructed. We cannot support mutation on this field simply, as downstream components do not support this.
  • The SystemConfiguration is also used to influence the defaults for new namespaces, read by namespace operator in the Supervisor. This change is providing an overlay on top of the system configuration defaults for very specific fields when applying to new namespaces.

As such, a WorkloadNetworkConfiguration with provider vpc may have:

  • NSX Project: /orgs/default/projects/foo
  • VPC Connectivity Profile: /orgs/default/projects/foo/vpc-connectivity-profiles/bar
  • Default Private CIDRs: [172.24.0.0/16]

This will construct a system NamespaceNetworkConfiguration with these same settings, and new namespaces would similarly adopt these settings. By applying this overlay, we can allow new namespaces to adopt a modified "Default Private CIDRs" without influencing the system NNC, which is non-modifiable.

So, with the defaultNamespaceConfiguration.defaultPrivateCIDRs set to something like [172.25.0.0/16], now a new namespace will use:

  • NSX Project: /orgs/default/projects/foo
  • VPC Connectivity Profile: /orgs/default/projects/foo/vpc-connectivity-profiles/bar
  • Default Private CIDRs: [172.25.0.0/16] <-- Note that it's now 172.25.0.0/16 instead of 172.24.0.0/16

ihgann added 2 commits July 9, 2026 13:45
Adds an optional defaultNamespaceConfiguration field to
NetworkProviderEntry, letting the vpc provider's namespace-onboarding
defaults (currently just privateCIDRs) be changed independently of the
append-only/immutable systemConfiguration.vpcConfig, per the design
spec (docs/superpowers/specs/2026-06-30-default-namespace-configuration-design.md).

NetworkProviderDefaultConfig is a value type with omitzero (not a
pointer) to satisfy KAL's optionalfields check, now that the
controller-tools bump makes required-field generation independent of
that choice. This required guarding the new CEL rule's nested has()
check at both levels (self.defaultNamespaceConfiguration and
.vpcConfig) rather than just the leaf, since has() errors instead of
returning false when the intermediate object is entirely absent from
the wire representation (as it will be for any WNC that doesn't set
defaultNamespaceConfiguration at all).

CEL test coverage for the new field lives in
test/cel/workloadnetworkconfiguration_test.go, appended to the ported
suite: valid override, rejection on non-vpc types, MinProperties=1 and
MinItems=1 rejection (via unstructured, since typed-client
omitempty/omitzero would otherwise drop the very empty values under
test), and full-replace admission (no append-only constraint, unlike
the system config).
@yahhhya

yahhhya commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

It is very likely I don't fully grasp the main idea of this change yet. IIUC, the idea here is to

  • EITHER introduce versioning the SystemConfiguration of a NetworkProviderEntry, to allow a Namespace's configuration to be frozen in time based on the version they were born in?
  • OR introduce a notion of "mutable" vs "immutable.

If true, I wonder if we should generalize the API to have versioning capability or "mutable vs immutable NNC fields"?

@ihgann

ihgann commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

It is very likely I don't fully grasp the main idea of this change yet. IIUC, the idea here is to

  • EITHER introduce versioning the SystemConfiguration of a NetworkProviderEntry, to allow a Namespace's configuration to be frozen in time based on the version they were born in?
  • OR introduce a notion of "mutable" vs "immutable.

If true, I wonder if we should generalize the API to have versioning capability or "mutable vs immutable NNC fields"?

The system configuration directly influences the system NamespaceNetworkConfiguration that Supervisor installs. By modifying it, we are suggesting we should support this transition which we cannot. Introducing versioning could become tricky once we actually support transition, because then you have encoded versions of mutable/immutable fields pertaining to something that has a lot of forking logic.

The idea here is we are describing what is primarily a structured ConfigMap - with a primary System configuration, and overridable defaults for new namespaces.

IOW - the system configuration is the baseline configuration. New namespaces can have differing, overridden values that correlate to settings in the system configuration.

There is a side benefit to this model which is also to reflect how Simplified Supervisor is encoded, which does not actually have a system workload network configuration (we consider it management only) - although this change does not yet bring in that support.

// +kubebuilder:validation:items:MaxLength=64
// +kubebuilder:validation:items:Pattern=`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$`
// +listType=atomic
PrivateCIDRs []string `json:"privateCIDRs,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seeing this, I suddenly thought of a question:
Whether we need to do CEL validation about the CIDRs ? Such as defaultNamespaceConfiguration.vpcConfig.privateCIDRs and systemConfiguration.privateCIDRs overlapping conflict checking.

Besides, there is one more important thing.
Previously, wcpsvc was used to verify whether CIDRs overlapped. Currently, it seems that the nsx-operater side has not added this because it requires communication with the nsx-manager. Therefore, the nnc-controller has not added this check either. My svnc side has not added this verification either. Do we need to discuss with the nsx-operator team at which layer it is more appropriate to add this validation?

@yangna0420 yangna0420 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, but seems This branch has conflicts that must be resolved.

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.

3 participants