Skip to content

Commit cfe39ea

Browse files
authored
Merge pull request #93001 from JoeAldinger/OSDOCS-14169
OSDOCS-14169:CUDN localnet
2 parents fed1d35 + c946e00 commit cfe39ea

File tree

5 files changed

+162
-17
lines changed

5 files changed

+162
-17
lines changed

modules/nw-cudn-cr.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $ cat << EOF | oc apply -f -
2828
apiVersion: v1
2929
kind: Namespace
3030
metadata:
31-
name: <cudn_namespace_name>
31+
name: <cudn_namespace_name>
3232
labels:
3333
k8s.ovn.org/primary-user-defined-network: ""
3434
EOF
@@ -59,7 +59,7 @@ spec:
5959
----
6060
<1> Name of your `ClusterUserDefinedNetwork` CR.
6161
<2> A label query over the set of namespaces that the cluster UDN CR applies to. Uses the standard Kubernetes `MatchLabel` selector. Must not point to `default` or `openshift-*` namespaces.
62-
<3> Uses the `matchLabels` selector type, where terms are evaluated with an `AND` relationship.
62+
<3> Uses the `matchLabels` selector type, where terms are evaluated with an `AND` relationship.
6363
<4> Because the `matchLabels` selector type is used, provisions namespaces that contain both `<label_1_key>=<label_1_value>` and `<label_2_key>=<label_2_value>` labels.
6464
<5> Describes the network configuration.
6565
<6> The `topology` field describes the network configuration; accepted values are `Layer2` and `Layer3`. Specifying a `Layer2` topology type creates one logical switch that is shared by all nodes.
@@ -96,7 +96,7 @@ spec:
9696
----
9797
<1> Name of your `ClusterUserDefinedNetwork` CR.
9898
<2> A label query over the set of namespaces that the cluster UDN applies to. Uses the standard Kubernetes `MatchLabel` selector. Must not point to `default` or `openshift-*` namespaces.
99-
<3> Uses the `matchExpressions` selector type, where terms are evaluated with an `OR` relationship.
99+
<3> Uses the `matchExpressions` selector type, where terms are evaluated with an `OR` relationship.
100100
<4> Specifies the label key to match.
101101
<5> Specifies the operator. Valid values include: `In`, `NotIn`, `Exists`, and `DoesNotExist`.
102102
<6> Because the `matchExpressions` type is used, provisions namespaces matching either `<example_namespace_one>` or `<example_namespace_two>`.

modules/nw-cudn-localnet.adoc

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
//module included in the following assembly:
2+
//
3+
// * networking/multiple_networks/primary_networks/about-user-defined-networks.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="nw-cudn-localnet_{context}"]
7+
= Creating a ClusterUserDefinedNetwork CR for a Localnet topology
8+
9+
A `Localnet` topology connects the secondary network to the physical underlay. This enables both east-west cluster traffic and access to services running outside the cluster. This topology type requires the additional configuration of the underlying Open vSwitch (OVS) system on cluster nodes.
10+
11+
.Prerequisites
12+
13+
* You are logged in as a user with `cluster-admin` privileges.
14+
15+
* You created and configured the Open vSwitch (OVS) bridge mapping to associate the logical OVN-Kubernetes network with the physical node network through the OVS bridge. For more information, see "Configuration for a localnet switched topology".
16+
17+
.Procedure
18+
19+
. Create a cluster-wide user-defined network with a `Localnet` topology:
20+
21+
.. Create a YAML file, such as `cluster-udn-localnet.yaml`, to define your request for a `Localnet` topology as in the following example:
22+
+
23+
[source, yaml]
24+
----
25+
apiVersion: k8s.ovn.org/v1
26+
kind: ClusterUserDefinedNetwork
27+
metadata:
28+
name: <cudn_name> # <1>
29+
spec:
30+
namespaceSelector: # <2>
31+
matchLabels: # <3>
32+
"<label_1_key>": "<label_1_value>" # <4>
33+
"<label_2_key>": "<label_2_value>" # <4>
34+
network: # <5>
35+
topology: Localnet # <6>
36+
localnet: # <7>
37+
role: Secondary # <8>
38+
physicalNetworkName: test
39+
ipam: {lifecycle: Persistent}
40+
subnets: ["192.168.0.0/16", "2001:dbb::/64"] # <9>
41+
----
42+
<1> Name of your `ClusterUserDefinedNetwork` (CUDN) CR.
43+
<2> A label query over the set of namespaces that the cluster CUDN CR applies to. Uses the standard Kubernetes `MatchLabel` selector. Must not point to `default`, `openshift-*`, or any other system namespaces.
44+
<3> Uses the `matchLabels` selector type, where terms are evaluated with an `AND` relationship.
45+
<4> In this example, the CUDN CR is deployed to namespaces that contain both `<label_1_key>=<label_1_value>` and `<label_2_key>=<label_2_value>` labels.
46+
<5> Describes the network configuration.
47+
<6> Specifying a `Localnet` topology type creates one logical switch that is directly bridged to one provider network.
48+
<7> This field specifies the `localnet` topology.
49+
<8> Specifies the `role` for the network configuration. `Secondary` is the only `role` specification supported for the `localnet` topology.
50+
<9> For `Localnet` topology types the following specifies config details for the `subnet` field:
51+
+
52+
* The subnets field is optional.
53+
* The subnets field is of type `string` and accepts standard CIDR formats for both IPv4 and IPv6.
54+
* The subnets field accepts one or two items. For two items, they must be of a different IP family. For example, subnets values of `10.100.0.0/16` and `2001:db8::/64`.
55+
* `localnet` subnets can be omitted. If omitted, users must configure static IP addresses for the pods. As a consequence, port security only prevents MAC spoofing. For more information, see "Configuring pods with a static IP address".
56+
57+
. Apply your request by running the following command:
58+
+
59+
[source,terminal]
60+
----
61+
$ oc create --validate=true -f <example_cluster_udn>.yaml
62+
----
63+
where:
64+
`<example_cluster_udn>.yaml`:: Is the name of your `Localnet` configuration file.
65+
66+
. Verify that your request is successful by running the following command:
67+
+
68+
[source,terminal]
69+
----
70+
$ oc get clusteruserdefinednetwork <cudn_name> -o yaml
71+
----
72+
where:
73+
`<cudn_name>`:: Is the name you created of your cluster-wide user-defined network.
74+
75+
.Example output
76+
[%collapsible]
77+
====
78+
[source,yaml]
79+
----
80+
apiVersion: k8s.ovn.org/v1
81+
kind: ClusterUserDefinedNetwork
82+
metadata:
83+
creationTimestamp: "2025-05-28T19:30:38Z"
84+
finalizers:
85+
- k8s.ovn.org/user-defined-network-protection
86+
generation: 1
87+
name: cudn-test
88+
resourceVersion: "140936"
89+
uid: 7ff185fa-d852-4196-858a-8903b58f6890
90+
spec:
91+
namespaceSelector:
92+
matchLabels:
93+
"1": "1"
94+
"2": "2"
95+
network:
96+
localnet:
97+
ipam:
98+
lifecycle: Persistent
99+
physicalNetworkName: test
100+
role: Secondary
101+
subnets:
102+
- 192.168.0.0/16
103+
- 2001:dbb::/64
104+
topology: Localnet
105+
status:
106+
conditions:
107+
- lastTransitionTime: "2025-05-28T19:30:38Z"
108+
message: 'NetworkAttachmentDefinition has been created in following namespaces:
109+
[test1, test2]'
110+
reason: NetworkAttachmentDefinitionCreated
111+
status: "True"
112+
type: NetworkCreated
113+
----
114+
====

modules/nw-udn-additional-config-details.adoc

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ The following table explains additional configurations for `ClusterUserDefinedNe
2121

2222
The `joinSubnets` field configures the routing between different segments within a user-defined network. Dual-stack clusters can set 2 subnets, one for each IP family; otherwise, only 1 subnet is allowed. This field is only allowed for the `Primary` network.
2323

24+
|`spec.network.<topology>.excludeSubnets`
25+
|`spec.<topology>.exlcudeSubnets`
26+
|string
27+
|Specifies a list of CIDRs to be removed from the specified CIDRs in the `subnets` field. The CIDRs in this list must be in range of at least one subnet specified in `subnets`. When omitted, no IP addresses are excluded, and all IP addresses specified in the `subnets` field are subject to assignment. You must use standard CIDR notation. For example, `10.128.0.0/16`. This field must be omitted if the `subnets` field is not set or if the `ipam.mode` field is set to `Disabled`.
28+
29+
When deploying a secondary network with `Localnet` topology, the IP ranges used in your physical network must be explicitly listed in the `excludeSubnets` field to prevent IP duplication in your subnet.
30+
2431
|`spec.network.<topology>.ipam.lifecycle`
2532
|`spec.<topology>.ipam.lifecycle`
2633
|object
@@ -29,7 +36,7 @@ The `joinSubnets` field configures the routing between different segments within
2936
Setting a value of Persistent is only supported when `ipam.mode` parameter is set to `Enabled`.
3037

3138
|`spec.network.<topology>.ipam.mode`
32-
|`spec.network.<topology>.ipam.mode`
39+
|`spec.<topology>`ipam.mode`
3340
|object
3441
|The `mode` parameter controls how much of the IP configuration is managed by OVN-Kubernetes. The following options are available:
3542

@@ -43,8 +50,25 @@ When disabled, OVN-Kubernetes only assigns MAC addresses and provides layer 2 co
4350
|`spec.<topology>.mtu`
4451
|integer
4552
|The maximum transmission units (MTU). The default value is `1400`. The boundary for IPv4 is `576`, and for IPv6 it is `1280`.
53+
54+
|`spec.network.localnet.vlan`
55+
|N/A
56+
|object
57+
|This field is optional and configures the virtual local area network (VLAN) tagging and allows you to segment the physical network into multiple independent broadcast domains.
58+
59+
|`spec.network.localnet.vlan.mode`
60+
|N/A
61+
|object
62+
|Acceptable values are `Access`. A value of `Access` specifies that the network interface belongs to a single VLAN and all traffic will be labelled with an `id` that is configured in the `spec.network.localnet.vlan.mode.access.id` field. The `id` specifies the VLAN `id` (VID) for access ports. Values must be an integer between 1 and 4094.
63+
64+
|`spec.network.localnet.physicalNetworkName`
65+
|N/A
66+
|string
67+
|Specifies the name for a physical network interface. The value you specify must match the `network-name` parameter that you provided in your Open vSwitch (OVS) bridge mapping.
4668
|====
4769

4870
where:
4971

50-
`<topology>`:: Is one of `layer2` or `layer3`.
72+
`<topology>`:: Can be either `layer2` or `layer3` for the `UserDefinedNetwork` CR. For the `ClusterUserDefinedNetwork` CR the topology can also be `Localnet`.
73+
74+

modules/support-matrix-for-udn-nad.adoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ User-defined networks and network attachment definitions can serve as both the p
1212

1313
[NOTE]
1414
====
15-
As of {product-title} 4.18, the Localnet topology is unavailable for use with the `UserDefinedNetwork` and `ClusterUserDefinedNetwork` CRs. It is only available for `NetworkAttachmentDefinition` CRs that leverage secondary networks.
15+
As of {product-title} 4.19, the `Localnet` topology is generally available for the `ClusterUserDefinedNetwork` CRs and is the preferred method for connecting physical networks to virtual networks. Alternatively, the `NetworkAttachmentDefinition` CR can also be used to create secondary networks with `Localnet` topologies.
1616
====
1717

1818
The following section highlights the supported features of the `UserDefinedNetwork` and `NetworkAttachmentDefinition` CRs when they are used as either the primary or secondary network. A separate table for the `ClusterUserDefinedNetwork` CR is also included.
@@ -116,45 +116,54 @@ The following section highlights the supported features of the `UserDefinedNetwo
116116
1. The Localnet topology is unavailable for use with the `UserDefinedNetwork` CR. It is only supported on secondary networks for `NetworkAttachmentDefinition` CRs.
117117

118118
.Support matrix for `ClusterUserDefinedNetwork` CRs
119-
[cols="1a,1a,1a, options="header"]
119+
[cols="1a,1a,1a,1a, options="header"]
120120
|===
121-
^| Network feature ^| Layer2 topology ^|Layer3 topology
121+
^| Network feature ^| Layer2 topology ^|Layer3 topology ^|Localnet topology
122122

123123
^| east-west traffic
124124
^| &#10003;
125125
^| &#10003;
126+
^| &#10003;
126127

127128
^| north-south traffic
128129
^| &#10003;
129130
^| &#10003;
131+
^| &#10003;
130132

131133
^| Persistent IPs
132134
^| &#10003;
133135
^| X
136+
^| &#10003;
134137

135138
^| Services
136139
^| &#10003;
137140
^| &#10003;
141+
^|
138142

139143
^| Routes
140144
^| X
141145
^| X
146+
^|
142147

143148
^| `EgressIP` resource
144149
^| &#10003;
145150
^| &#10003;
151+
^|
146152

147153
^| Multicast ^[1]^
148154
^| X
149155
^| &#10003;
156+
^|
150157

151158
^| `MultinetworkPolicy` resource
152159
^| X
153160
^| X
161+
^| &#10003;
154162

155163
^| `NetworkPolicy` resource ^[2]^
156164
^| &#10003;
157165
^| &#10003;
166+
^|
158167

159168
|===
160169
1. Multicast must be enabled in the namespace, and it is only available between OVN-Kubernetes network pods. For more information, see "About multicast".

networking/multiple_networks/primary_networks/about-user-defined-networks.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ include::modules/nw-cudn-best-practices.adoc[leveloffset=+2]
3434
//How to implement the CUDN API on a cluster by using the CLI.
3535
include::modules/nw-cudn-cr.adoc[leveloffset=+2]
3636

37+
//How to implement the CUDN API for localnet using the CLI.
38+
include::modules/nw-cudn-localnet.adoc[leveloffset=+2]
39+
40+
[role="_additional-resources"]
41+
.Additional resources
42+
* xref:../../../networking/multiple_networks/secondary_networks/creating-secondary-nwt-ovnk#configuration-localnet-switched-topology_configuring-additional-network-ovnk[Configuration for a localnet switched topology]
43+
3744
//How to implement the CUDN API on a cluster by using the UI.
3845
include::modules/nw-cudn-cr-ui.adoc[leveloffset=+2]
3946

@@ -65,12 +72,3 @@ include::modules/cudn-status-conditions.adoc[leveloffset=+1]
6572

6673
include::modules/opening-default-network-ports-udn.adoc[leveloffset=+1]
6774

68-
//Support matrix for UDN
69-
//include::modules
70-
71-
//Examples for Layer2 and Layer3
72-
//include::modules/nw-udn-examples.adoc[leveloffset=+2]
73-
74-
//[role="_additional-resources"]
75-
//== Additional resources
76-
// * xr3f../virtual docs that point to live migration of vms for 4.18's GA.

0 commit comments

Comments
 (0)