Skip to content

SecurityPolicy: per-mode service instances for T1/VPC mixed-mode#1413

Open
heypnus wants to merge 3 commits into
vmware-tanzu:mainfrom
heypnus:m1-security-policy
Open

SecurityPolicy: per-mode service instances for T1/VPC mixed-mode#1413
heypnus wants to merge 3 commits into
vmware-tanzu:mainfrom
heypnus:m1-security-policy

Conversation

@heypnus
Copy link
Copy Markdown
Contributor

@heypnus heypnus commented Apr 19, 2026

Replace the single SecurityPolicyService singleton with a per-mode map
keyed by VPCMode (bool). Each SecurityPolicyReconciler now carries an
isVPCMode field that determines which CRD it watches and which service
instance it uses. In mixed-mode clusters, two independent reconcilers
are registered — one for T1 namespaces, one for VPC namespaces.

heypnus and others added 3 commits April 14, 2026 15:28
Replace the global boolean cf.CoeConfig.EnableVPCNetwork with
namespace-driven mixed-mode state: HasT1Namespaces and
HasVPCNamespaces.

New module: pkg/config/mixed_mode.go
- Checks SupervisorCapabilities CRD for supports_per_namespace_network_providers
  capability.
- If supported: scans namespace annotations `nsx.vmware.com/vpc_network_config`
  to derive HasVPCNamespaces and HasT1Namespaces.
- If not supported (legacy/pre-9.2): falls back to EnableVPCNetwork
  config flag.

This enables NSX Operator to run in mixed mode where both T1 and VPC
namespaces coexist, as required for VDS->VPC and T1->VPC migration.

NOTE: This patch only ensures that the existing pure T1 or pure VPC envs
preserve existing behaviours. The full functionality will be
implemented in the follow-up patches.

Testing done:
https://jenkins-vcf-wcp-dev.devops.broadcom.net/job/dev-integ-nsxt/5639/
https://jenkins-vcf-wcp-dev.devops.broadcom.net/job/dev-nsxvpc/16738/
Introduce config.IsVPCNamespace() to decide whether a namespace is
served by VPC-only controllers: in mixed mode it checks the
namespace annotation for ProviderNSXVPC; in legacy mode (when
per-namespace providers are not supported) it uses the cluster-wide
HasVPCNamespaces flag set by InitMixedMode from EnableVPCNetwork.

controllers/common: add VPCNamespacePredicate and register it with
WithEventFilter on VPC-only controllers so non-VPC namespace
creates and updates are dropped before the work queue; Delete events
stay allowed for cleanup

controllers/namespace: Reconcile skips non-VPC namespaces

Testing done:
https://jenkins-vcf-wcp-dev.devops.broadcom.net/job/dev-integ-nsxt/5639/
https://jenkins-vcf-wcp-dev.devops.broadcom.net/job/dev-nsxvpc/16738/
Replace the single SecurityPolicyService singleton with a per-mode map
keyed by VPCMode (bool). Each SecurityPolicyReconciler now carries an
isVPCMode field that determines which CRD it watches and which service
instance it uses. In mixed-mode clusters, two independent reconcilers
are registered — one for T1 namespaces, one for VPC namespaces.
@heypnus heypnus force-pushed the m1-security-policy branch from 2b7c07f to dcd01f8 Compare April 20, 2026 02:28
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.

1 participant