Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: Add nmstate examples #531

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 217 additions & 5 deletions modules/ROOT/pages/sysconfig-network-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ See https://coreos.github.io/afterburn/usage/initrd-network-cmdline/[the Afterbu

WARNING: If you need networking to grab your Ignition config and your environment requires more complex networking than the default of DHCP to grab the Ignition config, then you'll need to use another method other than Ignition to configure the network.

Networking configuration can be performed by writing out files described in an Ignition config. These are https://networkmanager.dev/docs/api/latest/nm-settings-keyfile.html[NetworkManager keyfiles] that are written to `/etc/NetworkManager/system-connections/` that tell NetworkManager what to do.
There are to main methods for configuring networking with ignition
- By creating NetworkManager configuration files described in an Ignition config. These are https://networkmanager.dev/docs/api/latest/nm-settings-keyfile.html[NetworkManager keyfiles] that are written to `/etc/NetworkManager/system-connections/` that tell NetworkManager what to do.
- By creating a nmstate .yml files at /etc/nmstate following https://nmstate.io[NMstate syntax]. The applied network state file will be renamed with postfix .applied to prevent repeated applied on next run.

Any configuration provided via Ignition will be considered at a higher priority than any other method of configuring the Network for a Fedora CoreOS instance. If you specify Networking configuration via Ignition, try not to use other mechanisms to configure the network.

An example https://docs.fedoraproject.org/en-US/fedora-coreos/producing-ign/[Butane] config for the same static networking example that we showed above is:

NetworkManager
[source, yaml]
----
variant: fcos
Expand All @@ -127,10 +130,38 @@ storage:
method=manual
----

NMstate
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/ens2.yml
mode: 0600
contents:
inline: |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original example are expecting a static hostname. So we can state here in nmstate like:

hostname:
  config: myhost

dns-resolver:
config:
search: []
server:
- 8.8.8.8
interfaces:
- name: ens2
type: ethernet
ipv4:
enable: true
may-fail: false
address:
- ip: 10.10.10.10
prefix-length: 24
- ip: 10.10.10.1
prefix-length: 24

----
== Host Network Configuration Examples

In this section we'll go through common examples of setting up different types of networking devices using both dracut kernel arguments as well as NetworkManager keyfiles via Ignition/Butane.
In this section we'll go through common examples of setting up different types of networking devices using dracut kernel arguments, NetworkManager keyfiles and nmstate via Ignition/Butane.

Examples in this section that use a static IP will assume these values unless otherwise stated:

Expand Down Expand Up @@ -244,7 +275,7 @@ ip=${ip}::${gateway}:${netmask}:${hostname}:${interface}:none:${nameserver}
ip=10.10.10.10::10.10.10.1:255.255.255.0:myhostname:ens2:none:8.8.8.8
----

==== Butane config
==== Butane NetworkManager config

.Template
[source, yaml]
Expand Down Expand Up @@ -294,7 +325,59 @@ storage:
method=manual
----

==== Butane Nmstate config

.Template
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/${interface}.yml
mode: 0600
contents:
inline: |
routes:
- destination: 0.0.0.0/0
next-hop-address: ${gateway}
next-hop-interface: ${interface}
interfaces:
- name: ${interface}
type: ethernet
ipv4:
enable: true
may-fail: false
address:
- ip: ${ip}
prefix-length: ${prefix}
----

.Rendered
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/ens2.yml
mode: 0600
contents:
inline: |
routes:
- destination: 0.0.0.0/0
next-hop-address: 10.10.10.1
next-hop-interface: ens2
interfaces:
- name: ens2
type: ethernet
ipv4:
enable: true
may-fail: false
address:
- ip: 10.10.10.10
prefix-length: 24
----

=== Configuring a Bond (Static IP)

Expand All @@ -314,7 +397,7 @@ ip=10.10.10.10::10.10.10.1:255.255.255.0:myhostname:bond0:none:8.8.8.8
bond=bond0:ens2,ens3:mode=active-backup,miimon=100
----

==== Butane config
==== Butane NetworkManager config

.Template
[source, yaml]
Expand Down Expand Up @@ -410,6 +493,88 @@ storage:
slave-type=bond
----

==== Butane NMstate config

.Template
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/${bondname}.yml
mode: 0600
contents:
inline: |
dns-resolver:
config:
search: []
server:
- ${nameserver}
routes:
config:
destination: 0.0.0.0/0
next-hop-interface: ${bondname}
next-hop-address: ${gateway}
interfaces:
- name: ${bondname}
type: bond
state: up
ipv4:
enabled: true
may-fail: true
address:
- ip: ${ip}
prefix-length: 24
link-aggregation:
mode: active-backup
options:
miimon: '100'
ports:
- ${subnic1}
- ${subnic2}
----

.Rendered
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/bond0.yml
mode: 0600
contents:
inline: |
dns-resolver:
config:
search: []
server:
- 8.8.8.8
routes:
config:
destination: 0.0.0.0/0
next-hop-interface: bond0
next-hop-address: 10.10.10.1
interfaces:
- name: bond0
type: bond
state: up
ipv4:
enabled: true
may-fail: true
address:
- ip: 10.10.10.10
prefix-length: 24
link-aggregation:
mode: active-backup
options:
miimon: '100'
ports:
- ens2
- ens3
----


=== Configuring a Bridge (DHCP)

Expand All @@ -429,7 +594,7 @@ ip=br0:dhcp
bridge=br0:ens2,ens3
----

==== Butane config
==== Butane NetworkManager config

.Template
[source, yaml]
Expand Down Expand Up @@ -519,6 +684,53 @@ storage:
[bridge-port]
----

==== Butane MNstate config

.Template
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/${bridgename}.yml
mode: 0600
contents:
inline: |
interfaces:
- name: ${bridgename}
type: linux-bridge
ipv4:
enabled: true
dhcp: true
bridge:
ports:
- name: ${subnic1}
- name: ${subnic2}
----

.Rendered
[source, yaml]
----
variant: fcos
version: 1.4.0
storage:
files:
- path: /etc/nmstate/br0.yml
mode: 0600
contents:
inline: |
interfaces:
- name: br0
type: linux-bridge
ipv4:
enabled: true
dhcp: true
bridge:
ports:
- name: ens2
- name: ens3
----

=== Configuring a Team (DHCP)

Expand Down