|
| 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 | +==== |
0 commit comments