|
| 1 | +//module included in the following assembly: |
| 2 | +// |
| 3 | +// *networking/multiple_networks/understanding-user-defined-networks.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="nw-udn-cr_{context}"] |
| 7 | += Creating a UserDefinedNetwork custom resource |
| 8 | + |
| 9 | +The following procedure sets up a user-defined network that is namespace scoped. |
| 10 | + |
| 11 | +//We won't have these pieces till GA in 4.18. |
| 12 | +//[NOTE] |
| 13 | +//==== |
| 14 | +//If any cluster default networked pods exist before the user-defined network is created, any further pods created in this namespace will return an error message: `What_is_this`. |
| 15 | +//==== |
| 16 | + |
| 17 | +.Procedure |
| 18 | + |
| 19 | +. Create a request for a user-defined network: |
| 20 | + |
| 21 | +.. Create a YAML file, such as `my-udn-request.yaml`, to define your request with content as in the following example: |
| 22 | ++ |
| 23 | +[source, yaml] |
| 24 | +---- |
| 25 | +apiVersion: k8s.ovn.org/v1 |
| 26 | +kind: UserDefinedNetwork |
| 27 | +metadata: |
| 28 | + name: udn-1 # <1> |
| 29 | + namespace: <some_custom_namespace> |
| 30 | +spec: |
| 31 | + topology: Layer2 # <2> |
| 32 | + layer2: <3> |
| 33 | + role: Primary # <4> |
| 34 | + mtu: 9000 # <5> |
| 35 | + subnets: |
| 36 | + - "10.0.0.0/24" |
| 37 | + - "2001:db8::/64" # <6> |
| 38 | + JoinSubnets: [] # <7> |
| 39 | + IPAMLifecycle: Persistent # <8> |
| 40 | +---- |
| 41 | +<1> Name of your `UserDefinedNetwork` resource. This should not be `default` or duplicate any global namespaces created by the Cluster Network Operator (CNO). |
| 42 | +<2> The `topology` field describes the network configuration, accepted values are `Layer2` and `Layer3`. `Layer3` topology creates a layer 2 segment per node, each with a different subnet. Layer 3 routing is used to interconnect node subnets. `Layer2` topology creates one logical switch shared by all nodes. |
| 43 | +<3> This field specifies the topology configuration, it can be `layer2` or `layer3`. |
| 44 | +<4> Specifies `Primary` or `Secondary`. `Primary` is the only `role` specification supported in {product-version}. |
| 45 | +<5> The maximum transmission units (MTU) is an optional field. The default value is `1400`. The boundary for IPv4 is 574, and for IPv6 it is 1280. |
| 46 | +<6> Specifies the subnet to be used for the network across the cluster. Supports both IPv6 and dual-stack. For example, `192.168.100.0/24`,`2001:DBB::/64`. Dual-stack may set two subnets otherwise only one is allowed. When the `topology` field is set to `Layer3`, the subnet is split into smaller subnets for every node. Accepted format for subnets when `Layer3` is set are: `172.16.0.0/16/24`. For `Layer2` values in `topology` field, standard CIDR ranges are accepted. If omitted the network only provides `Layer2` communication and you must configure IP addresses. |
| 47 | +<7> Specifies the `subnets` used inside the OVN-Kubernetes network topology. If omitted, the OVN-Kubernetes network plugin assigns one, which is subject to change over time. |
| 48 | +<8> Specifies the IP address management system (IPAM). This field is optional and allowed when `topology` is `layer2`. The |
| 49 | +`subnets` field must be specified when this field is specified. The `Persistent` value specifies that workloads have persistent IP addresses. Assigned by the container network interface (CNI) and used by OVN-Kubernetes to program pod IP addresses. You must not change this for pod annotations. |
| 50 | + |
| 51 | +.. Apply your request by running the following command: |
| 52 | ++ |
| 53 | +[source,terminal] |
| 54 | +---- |
| 55 | +$ oc apply -f my-udn-request.yaml |
| 56 | +---- |
| 57 | + |
| 58 | +. Verify that your request is successful by running the following command: |
| 59 | ++ |
| 60 | +[source, terminal] |
| 61 | +---- |
| 62 | +$ oc get userdefinednetworks udn-1 -n default -o yaml |
| 63 | +---- |
| 64 | ++ |
| 65 | +.Example output |
| 66 | +[source,terminal] |
| 67 | +---- |
| 68 | +apiVersion: k8s.ovn.org/v1 |
| 69 | +kind: UserDefinedNetwork |
| 70 | +metadata: |
| 71 | + creationTimestamp: "2024-08-28T17:18:47Z" |
| 72 | + finalizers: |
| 73 | + - k8s.ovn.org/user-defined-network-protection |
| 74 | + generation: 1 |
| 75 | + name: udn-1 |
| 76 | + namespace: some-custom-namespace |
| 77 | + resourceVersion: "53313" |
| 78 | + uid: f483626d-6846-48a1-b88e-6bbeb8bcde8c |
| 79 | +spec: |
| 80 | + layer2: |
| 81 | + mtu: 9000 |
| 82 | + role: Primary |
| 83 | + subnets: |
| 84 | + - 10.0.0.0/24 |
| 85 | + topology: Layer2 |
| 86 | +status: |
| 87 | + conditions: |
| 88 | + - lastTransitionTime: "2024-08-28T17:18:47Z" |
| 89 | + message: NetworkAttachmentDefinition has been created |
| 90 | + reason: NetworkAttachmentDefinitionReady |
| 91 | + status: "True" |
| 92 | + type: NetworkReady |
| 93 | +---- |
| 94 | + |
0 commit comments