Skip to content

Commit 762ca7a

Browse files
authored
Merge pull request #40886 from sjhala-ccs/cnv-13661
CNV-13661: Added example for inheriting static IP from NIC
2 parents a761b52 + 404c52b commit 762ca7a

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/node_network/virt-updating-node-network-config.adoc
4+
5+
:_content-type: REFERENCE
6+
[id="virt-example-inherit-static-ip-from-nic_{context}"]
7+
= Example: Linux bridge interface node network configuration policy to inherit static IP address from the NIC attached to the bridge
8+
9+
Create a Linux bridge interface on nodes in the cluster and transfer the static IP configuration of the NIC to the bridge by applying a single `NodeNetworkConfigurationPolicy` manifest to the cluster.
10+
11+
The following YAML file is an example of a manifest for a Linux bridge interface. It includes sample values that you must replace with your own information.
12+
13+
14+
[source,yaml]
15+
----
16+
apiVersion: nmstate.io/v1
17+
kind: NodeNetworkConfigurationPolicy
18+
metadata:
19+
name: br1-eth1-copy-ipv4-policy <1>
20+
spec:
21+
nodeSelector: <2>
22+
node-role.kubernetes.io/worker: ""
23+
capture:
24+
eth1-nic: interfaces.name=="eth1" <3>
25+
eth1-routes: routes.running.next-hop-interface=="eth1"
26+
br1-routes: capture.eth1-routes | routes.running.next-hop-interface := "br1"
27+
desiredState:
28+
interfaces:
29+
- name: br1
30+
description: Linux bridge with eth1 as a port
31+
type: linux-bridge <4>
32+
state: up
33+
ipv4: "{{ capture.eth1-nic.interfaces.0.ipv4 }}" <5>
34+
bridge:
35+
options:
36+
stp:
37+
enabled: false
38+
port:
39+
- name: eth1 <6>
40+
routes:
41+
config: "{{ capture.br1-routes.routes.running }}"
42+
----
43+
<1> The name of the policy.
44+
<2> Optional: If you do not include the `nodeSelector` parameter, the policy applies to all nodes in the cluster. This example uses the `node-role.kubernetes.io/worker: ""` node selector to select all worker nodes in the cluster.
45+
<3> The reference to the node NIC to which the bridge attaches.
46+
<4> The type of interface. This example creates a bridge.
47+
<5> The IP address of the bridge interface. This value matches the IP address of the NIC which is referenced by the `spec.capture.eth1-nic` entry.
48+
<6> The node NIC to which the bridge attaches.

virt/node_network/virt-updating-node-network-config.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[id="virt-updating-node-network-config"]
33
= Updating node network configuration
44
include::modules/virt-document-attributes.adoc[]
5-
:context: virt-updating-node-network-config
5+
:context: virt-updating-node-network-config
66

77
toc::[]
88

@@ -36,6 +36,18 @@ include::modules/virt-example-ethernet-nncp.adoc[leveloffset=+2]
3636

3737
include::modules/virt-example-nmstate-multiple-interfaces.adoc[leveloffset=+2]
3838

39+
[id="capturing-nic-static-ip_virt-updating-node-network-config"]
40+
== Capturing the static IP of a NIC attached to a bridge
41+
42+
ifdef::openshift-enterprise[]
43+
:FeatureName: Capturing the static IP of a NIC
44+
include::snippets/technology-preview.adoc[leveloffset=+2]
45+
endif::[]
46+
47+
include::modules/virt-example-inherit-static-ip-from-nic.adoc[leveloffset=+2]
48+
49+
.Additional resources
50+
* link:https://nmstate.io/nmpolicy/user-guide/102-policy-syntax.html[The NMPolicy project - Policy syntax]
51+
3952
// Dropping offset by one again
4053
include::modules/virt-example-nmstate-IP-management.adoc[leveloffset=+1]
41-

0 commit comments

Comments
 (0)