Skip to content

mbp-1126: Network segmentation using UDN - #147

Draft
mlorenzofr wants to merge 2 commits into
validatedpatterns:mainfrom
mlorenzofr:mbp-1126
Draft

mbp-1126: Network segmentation using UDN#147
mlorenzofr wants to merge 2 commits into
validatedpatterns:mainfrom
mlorenzofr:mbp-1126

Conversation

@mlorenzofr

@mlorenzofr mlorenzofr commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Implements network segmentation using User Defined Networks (UDNs) for the qtodo multi-tier application. The qtodo frontend (qtodo namespace) and PostgreSQL database (qtodo-db namespace) join a shared Layer2 secondary ClusterUserDefinedNetwork (CUDN) so database traffic is isolated from the default cluster network.

Because secondary UDNs do not support Kubernetes Services, the database pod uses a static UDN IP and qtodo's JDBC URL targets that address when UDN is enabled.

Summary

  • Adds a cluster-scoped ClusterUserDefinedNetwork in the qtodo-db chart spanning the qtodo and qtodo-db namespaces
  • Lets OVN-Kubernetes create the per-namespace NetworkAttachmentDefinition; pods opt in via the k8s.v1.cni.cncf.io/networks annotation
  • Configures MultiNetworkPolicy on the UDN to allow PostgreSQL (5432/tcp) only from app=qtodo to app=qtodo-db
  • Tightens cluster-network NetworkPolicy when UDN is enabled:
    • qtodo: router, Vault, OIDC, and DNS on eth0. No cluster-network egress to PostgreSQL
    • qtodo-db: CoreDNS only on eth0. No PostgreSQL ingress on eth0
  • Updates qtodo deployment and PostgreSQL StatefulSet to attach to the shared UDN
  • Points qtodo JDBC at the static UDN IP (10.100.0.10) when UDN is enabled
  • Adds/updates documentation in docs/user-defined-networks.md and related docs
  • Extends the udn feature flag to enable both qtodo-db (udn.enabled) and qtodo (app.udn.enabled)

Prerequisites

  • spec.useMultiNetworkPolicy: true on network.operator.openshift.io/cluster (required for UDN MultiNetworkPolicy. Can be disabled via chart values if needed)

Test plan

  • Enable useMultiNetworkPolicy on the Cluster Network Operator
  • Generate and apply the UDN variant: python3 scripts/gen-feature-variants.py --features udn
  • Confirm the feature flag enables/disables CUDN and UDN policy resources in both qtodo and qtodo-db
  • Verify ClusterUserDefinedNetwork and NADs exist in both namespaces
  • Confirm qtodo and qtodo-db pods attach to the UDN (net1) and qtodo-db has IP 10.100.0.10
  • Validate cluster-network NetworkPolicy rules (qtodo-db: DNS egress only; no PostgreSQL on eth0)
  • Validate MultiNetworkPolicy rules on the UDN (PostgreSQL allowed qtodo -> qtodo-db only)
  • Test connectivity:
    • qtodo -> PostgreSQL via UDN IP succeeds
    • qtodo -> PostgreSQL via qtodo-db.qtodo-db.svc fails when UDN is enabled
    • qtodo -> Vault/OIDC/DNS via cluster network succeeds
    • qtodo-db -> CoreDNS via cluster network succeeds
  • Test the qtodo application end-to-end (login, create/delete todos)
  • Review updated documentation (docs/user-defined-networks.md, sync-wave inventory, multi-tier guide)

@mlorenzofr
mlorenzofr marked this pull request as draft June 23, 2026 16:52
@minmzzhang

Copy link
Copy Markdown
Collaborator

There seems to be a conflict role of the UDN. In udn-user-defined-netowrk.yaml, the layer2 role was set to Primary, however, in app-deployment.yaml, it uses k8s.v1.cni.cocf.io/networks annotations to attach pods to the UDN:

k8s.v1.cni.cncf.io/networks: {{ .Release.Namespace }}/{{ .Values.app.udn.nadName }}

@minmzzhang minmzzhang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shall we use Primary or Secondary role for this UDN work? If we use Primary, then no manual NAD should be needed and no pod annotations of k8s.v1.cni.cncf.io/networks

Comment thread docs/user-defined-networks.md Outdated
Comment thread charts/qtodo/templates/udn-admin-network-policy.yaml Outdated
Comment thread charts/qtodo/values.yaml Outdated
@mlorenzofr
mlorenzofr force-pushed the mbp-1126 branch 2 times, most recently from 4a61331 to ba01162 Compare September 9, 2026 15:38
@mlorenzofr
mlorenzofr marked this pull request as ready for review September 10, 2026 11:34
@mlorenzofr
mlorenzofr marked this pull request as draft September 10, 2026 15:41
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.

2 participants