Skip to content

Commit 71e73ed

Browse files
Merge pull request #26524 from aburdenthehand/cnv-7521-nmstate-examples
CNV-7522 - nmstate more config example
2 parents 9bf944e + fca6c95 commit 71e73ed

10 files changed

+253
-17
lines changed

modules/virt-about-nmstate.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Module included in the following assemblies:
22
//
33
// * virt/node_network/virt-observing-node-network-state.adoc
4+
// * virt/node_network/virt-updating-node-network-config.adoc
45

56
[id="virt-about-nmstate_{context}"]
67
= About nmstate
@@ -12,3 +13,13 @@ Node networking is monitored and updated by the following objects:
1213
`NodeNetworkState`:: Reports the state of the network on that node.
1314
`NodeNetworkConfigurationPolicy`:: Describes the requested network configuration on nodes. You update the node network configuration, including adding and removing interfaces, by applying a `NodeNetworkConfigurationPolicy` manifest to the cluster.
1415
`NodeNetworkConfigurationEnactment`:: Reports the network policies enacted upon each node.
16+
17+
{VirtProductName} supports the use of the following nmstate interface types:
18+
19+
* Linux Bridge
20+
21+
* VLAN
22+
23+
* Bond
24+
25+
* Ethernet

modules/virt-creating-interface-on-nodes.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ spec:
3939
- name: eth1
4040
----
4141
<1> Name of the Policy.
42-
<2> Optional. If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
42+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
4343
<3> This example uses the `node-role.kubernetes.io/worker: ""` node selector to select all worker nodes in the cluster.
44-
<4> Optional. Human-readable description for the interface.
44+
<4> Optional: Human-readable description for the interface.
4545

4646
. Create the Policy:
4747
+

modules/virt-example-bond-nncp.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ spec:
5050
mtu: 1450 <13>
5151
----
5252
<1> Name of the Policy.
53-
<2> Optional. If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
53+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
5454
<3> This example uses a `hostname` node selector.
5555
<4> Name of the interface.
56-
<5> Optional. Human-readable description of the interface.
56+
<5> Optional: Human-readable description of the interface.
5757
<6> The type of interface. This example creates a bond.
5858
<7> The requested state for the interface after creation.
59-
<8> Optional. If you do not use `dhcp`, you can either set a static IP or leave the interface without an IP address.
59+
<8> Optional: If you do not use `dhcp`, you can either set a static IP or leave the interface without an IP address.
6060
<9> Enables `ipv4` in this example.
6161
<10> The driver mode for the bond. This example uses an active backup mode.
62-
<11> Optional. This example uses miimon to inspect the bond link every 140ms.
62+
<11> Optional: This example uses miimon to inspect the bond link every 140ms.
6363
<12> The subordinate node NICs in the bond.
64-
<13> Optional. The maximum transmission unit (MTU) for the bond. If not specified, this value is set to `1500` by default.
64+
<13> Optional: The maximum transmission unit (MTU) for the bond. If not specified, this value is set to `1500` by default.

modules/virt-example-bridge-nncp.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ spec:
3737
- name: eth1 <11>
3838
----
3939
<1> Name of the Policy.
40-
<2> Optional. If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
40+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
4141
<3> This example uses a `hostname` node selector.
4242
<4> Name of the interface.
43-
<5> Optional. Human-readable description of the interface.
43+
<5> Optional: Human-readable description of the interface.
4444
<6> The type of interface. This example creates a bridge.
4545
<7> The requested state for the interface after creation.
46-
<8> Optional. If you do not use `dhcp`, you can either set a static IP or leave the interface without an IP address.
46+
<8> Optional: If you do not use `dhcp`, you can either set a static IP or leave the interface without an IP address.
4747
<9> Enables `ipv4` in this example.
4848
<10> Disables `stp` in this example.
4949
<11> The node NIC to which the bridge attaches.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/node_network/virt-updating-node-network-config.adoc
4+
5+
[id="virt-example-ethernet-nncp_{context}"]
6+
= Example: Ethernet interface NodeNetworkConfigurationPolicy
7+
8+
Configure an Ethernet interface on nodes in the cluster by applying a `NodeNetworkConfigurationPolicy` manifest to the cluster.
9+
10+
The following YAML file is an example of a manifest for an Ethernet interface.
11+
It includes sample values that you must replace with your own information.
12+
13+
[source,yaml]
14+
----
15+
apiVersion: nmstate.io/v1alpha1
16+
kind: NodeNetworkConfigurationPolicy
17+
metadata:
18+
name: eth1-policy <1>
19+
spec:
20+
nodeSelector: <2>
21+
kubernetes.io/hostname: <node01> <3>
22+
desiredState:
23+
interfaces:
24+
- name: eth1 <4>
25+
description: Configuring eth1 on node01 <5>
26+
type: ethernet <6>
27+
state: up <7>
28+
ipv4:
29+
dhcp: true <8>
30+
enabled: true <9>
31+
----
32+
<1> Name of the Policy.
33+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
34+
<3> This example uses a `hostname` node selector.
35+
<4> Name of the interface.
36+
<5> Optional: Human-readable description of the interface.
37+
<6> The type of interface. This example creates an Ethernet networking interface.
38+
<7> The requested state for the interface after creation.
39+
<8> Optional: If you do not use `dhcp`, you can either set a static IP or leave the interface without an IP address.
40+
<9> Enables `ipv4` in this example.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/node_network/virt-updating-node-network-config.adoc
4+
5+
[id="virt-example-nmstate-IP-management_{context}"]
6+
= Examples: IP management
7+
8+
The following example configuration snippets demonstrate different methods of IP management.
9+
10+
These examples use the `ethernet` interface type to simplify the example while showing the related context in the Policy configuration. These IP management examples can be used with the other interface types.
11+
12+
[id="virt-example-nmstate-IP-management-static_{context}"]
13+
== Static
14+
15+
The following snippet statically configures an IP address on the Ethernet interface:
16+
17+
[source,yaml]
18+
----
19+
...
20+
interfaces:
21+
- name: eth1
22+
description: static IP on eth1
23+
type: ethernet
24+
state: up
25+
ipv4:
26+
address:
27+
- ip: 192.168.122.250 <1>
28+
prefix-length: 24
29+
enabled: true
30+
...
31+
----
32+
<1> Replace this value with the static IP address for the interface.
33+
34+
[id="virt-example-nmstate-IP-management-no-ip_{context}"]
35+
== No IP address
36+
37+
The following snippet ensures that the interface has no IP address:
38+
39+
[source,yaml]
40+
----
41+
...
42+
interfaces:
43+
- name: eth1
44+
description: No IP on eth1
45+
type: ethernet
46+
state: up
47+
ipv4:
48+
enabled: false
49+
...
50+
----
51+
52+
[id="virt-example-nmstate-IP-management-dhcp_{context}"]
53+
== Dynamic host configuration
54+
55+
The following snippet configures an Ethernet interface that uses a dynamic IP address, gateway address, and DNS:
56+
57+
[source,yaml]
58+
----
59+
...
60+
interfaces:
61+
- name: eth1
62+
description: DHCP on eth1
63+
type: ethernet
64+
state: up
65+
ipv4:
66+
dhcp: true
67+
enabled: true
68+
...
69+
----
70+
71+
The following snippet configures an Ethernet interface that uses a dynamic IP address but does not use a dynamic gateway address or DNS:
72+
73+
[source,yaml]
74+
----
75+
...
76+
interfaces:
77+
- name: eth1
78+
description: DHCP without gateway or DNS on eth1
79+
type: ethernet
80+
state: up
81+
ipv4:
82+
dhcp: true
83+
auto-gateway: false
84+
auto-dns: false
85+
enabled: true
86+
...
87+
----
88+
89+
[id="virt-example-nmstate-IP-management-dns_{context}"]
90+
== DNS
91+
92+
The following snippet sets DNS configuration on the host.
93+
94+
[source,yaml]
95+
----
96+
...
97+
interfaces:
98+
...
99+
dns-resolver:
100+
config:
101+
search:
102+
- example.com
103+
- example.org
104+
server:
105+
- 8.8.8.8
106+
...
107+
----
108+
109+
[id="virt-example-nmstate-IP-management-static-routing_{context}"]
110+
== Static routing
111+
112+
The following snippet configures a static route and a static IP on interface `eth1`.
113+
114+
[source,yaml]
115+
----
116+
...
117+
interfaces:
118+
- name: eth1
119+
description: Static routing on eth1
120+
type: ethernet
121+
state: up
122+
ipv4:
123+
address:
124+
- ip: 192.0.2.251 <1>
125+
prefix-length: 24
126+
enabled: true
127+
routes:
128+
config:
129+
- destination: 198.51.100.0/24
130+
metric: 150
131+
next-hop-address: 192.0.2.1 <2>
132+
next-hop-interface: eth1
133+
table-id: 254
134+
...
135+
----
136+
<1> The static IP address for the Ethernet interface.
137+
<2> Next hop address for the node traffic. This must be in the same subnet as the IP address set for the Ethernet interface.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/node_network/virt-updating-node-network-config.adoc
4+
5+
[id="virt-example-nmstate-multiple-interfaces_{context}"]
6+
= Example: Multiple interfaces in the same Policy
7+
8+
You can create multiple interfaces in the same Policy. These interfaces can reference each other, allowing you to build and deploy a network configuration by using a single Policy manifest.
9+
10+
The following example snippet creates a bond that is named `bond10` across two NICs and a Linux bridge that is named `br1` that connects to the bond.
11+
12+
[source,yaml]
13+
----
14+
...
15+
interfaces:
16+
- name: bond10
17+
description: Bonding eth2 and eth3 for Linux bridge
18+
type: bond
19+
state: up
20+
link-aggregation:
21+
slaves:
22+
- eth2
23+
- eth3
24+
- name: br1
25+
description: Linux bridge on bond
26+
type: linux-bridge
27+
state: up
28+
bridge:
29+
port:
30+
- name: bond10
31+
...
32+
----

modules/virt-example-vlan-nncp.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ spec:
3131
id: 102 <9>
3232
----
3333
<1> Name of the Policy.
34-
<2> Optional. If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
34+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
3535
<3> This example uses a `hostname` node selector.
3636
<4> Name of the interface.
37-
<5> Optional. Human-readable description of the interface.
37+
<5> Optional: Human-readable description of the interface.
3838
<6> The type of interface. This example creates a VLAN.
3939
<7> The requested state for the interface after creation.
4040
<8> The node NIC to which the VLAN is attached.

modules/virt-removing-interface-from-nodes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
state: absent <4>
3636
----
3737
<1> Name of the Policy.
38-
<2> Optional. If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
38+
<2> Optional: If you do not include the `nodeSelector`, the Policy applies to all nodes in the cluster.
3939
<3> This example uses the `node-role.kubernetes.io/worker: ""` node selector to select all worker nodes in the cluster.
4040
<4> Changing the state to `absent` removes the interface.
4141

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[id="virt-updating-node-network"]
1+
[id="virt-updating-node-network-config"]
22
= Updating node network configuration
33
include::modules/virt-document-attributes.adoc[]
44
:context: virt-updating-node-network-config
@@ -11,15 +11,31 @@ include::modules/virt-about-nmstate.adoc[leveloffset=+1]
1111

1212
include::modules/virt-creating-interface-on-nodes.adoc[leveloffset=+1]
1313

14+
[discrete]
15+
== Additional resources
16+
* xref:virt-nmstate-example-policy-configurations[Example Policy configurations for different interfaces]
17+
* xref:virt-example-nmstate-multiple-interfaces_virt-updating-node-network-config[Example for creating multiple interfaces in the same Policy]
18+
* xref:virt-example-nmstate-IP-management_virt-updating-node-network-config[Examples of different IP management methods in Policies]
19+
1420
include::modules/virt-confirming-policy-updates-on-nodes.adoc[leveloffset=+1]
1521

1622
include::modules/virt-removing-interface-from-nodes.adoc[leveloffset=+1]
1723

1824
include::modules/virt-restoring-node-network-configuration.adoc[leveloffset=+1]
1925

20-
include::modules/virt-example-bridge-nncp.adoc[leveloffset=+1]
26+
[id="virt-nmstate-example-policy-configurations"]
27+
== Example Policy configurations for different interfaces
28+
29+
include::modules/virt-example-bridge-nncp.adoc[leveloffset=+2]
30+
31+
include::modules/virt-example-vlan-nncp.adoc[leveloffset=+2]
32+
33+
include::modules/virt-example-bond-nncp.adoc[leveloffset=+2]
34+
35+
include::modules/virt-example-ethernet-nncp.adoc[leveloffset=+2]
2136

22-
include::modules/virt-example-vlan-nncp.adoc[leveloffset=+1]
37+
include::modules/virt-example-nmstate-multiple-interfaces.adoc[leveloffset=+2]
2338

24-
include::modules/virt-example-bond-nncp.adoc[leveloffset=+1]
39+
// Dropping offset by one again
40+
include::modules/virt-example-nmstate-IP-management.adoc[leveloffset=+1]
2541

0 commit comments

Comments
 (0)