Write complete os-net-config examples

These illustrative examples are adapted from the tripleo-ansible
tripleo_network_config templates.

Since the README now points to the documentation, the partial
examples in the README have been removed.

[1] https://opendev.org/openstack/tripleo-ansible/src/branch/master/tripleo_ansible/roles/tripleo_network_config/templates

Change-Id: I3c5de53dd97bc5bbc25d3c02fe9a6185f3112e84
This commit is contained in:
Steve Baker 2021-02-15 20:43:54 +13:00
parent 6c9bdad27b
commit 79a41c4478
4 changed files with 245 additions and 98 deletions

View File

@ -33,70 +33,4 @@ project consists of:
at /etc/os-net-config/config.yaml. This can be customized via the
--config-file CLI option.
* A python library which provides configuration via an object model.
YAML Config Examples
--------------------
* Configure an OVS bridge with a single attached interface (port)
.. code-block:: yaml
network_config:
-
type: ovs_bridge
name: br-ctlplane
use_dhcp: true
ovs_extra:
- br-set-external-id br-ctlplane bridge-id br-ctlplane
members:
-
type: interface
name: em1
..
* Configure an OVS bridge on top of an OVS bond
.. code-block:: yaml
network_config:
-
type: ovs_bridge
name: br-ctlplane
use_dhcp: true
members:
-
type: ovs_bond
name: bond1
members:
-
type: interface
name: em1
-
type: interface
name: em2
..
* Configure a tagged VLAN interface on top of an OVS bridge
.. code-block:: yaml
network_config:
-
type: ovs_bridge
name: br-ctlplane
use_dhcp: true
members:
-
type: interface
name: em1
-
type: vlan
vlan_id: 16
addresses:
-
ip_netmask: 192.0.2.1/24
* A python library which provides configuration via an object model.

View File

@ -14,7 +14,8 @@ attributes are supported for that type.
Common attributes
-----------------
The following attributes are used in many types:
The following attributes are used in many types. See :ref:`multiple-nics` for
examples.
addresses
=========
@ -274,8 +275,9 @@ Will be appended to the ``OVS_OPTIONS`` value and the concatenated list of
type: interface
---------------
Configures a physical NIC. All of the :ref:`common-attributes` can be used with
this type along with the following attributes:
Configures a physical NIC. See :ref:`multiple-nics` for examples. All of the
:ref:`common-attributes` can be used with this type along with the following
attributes:
ethtool_opts
============
@ -311,9 +313,10 @@ Sets ``LINKDELAY`` to the delay value.
type: ovs_bridge
----------------
Configures an `Open vSwitch`_ bridge. All of the :ref:`common-attributes` and
:ref:`ovs-attributes` can be used with this type. The ``members`` attribute
contains a list of entries for interfaces to bridge typically of ``type``:
Configures an `Open vSwitch`_ bridge. See :ref:`control-plane-bridge` for an
example. All of the :ref:`common-attributes` and :ref:`ovs-attributes` can be
used with this type. The ``members`` attribute contains a list of entries for
interfaces to bridge typically of ``type``:
- ``interface``
- ``linux_bond``
@ -332,9 +335,10 @@ or ``use_dhcpv6`` is ``true``, ``OVSBOOTPROTO=dhcp`` is set and
type: ovs_bond
--------------
Configures an `Open vSwitch`_ bond. All of the :ref:`common-attributes` and
:ref:`ovs-attributes` can be used with this type. The ``members`` attribute
contains a list of entries for interfaces to be bonded.
Configures an `Open vSwitch`_ bond. See :ref:`ovs-bond` for an example. All
of the :ref:`common-attributes` and :ref:`ovs-attributes` can be used with
this type. The ``members`` attribute contains a list of entries for
interfaces to be bonded.
ifcfg implementation
====================
@ -346,8 +350,9 @@ or ``use_dhcpv6`` is ``true``, ``OVSBOOTPROTO=dhcp`` is set and
type: vlan
----------
Configures VLAN tagging for one VLAN. :ref:`common-attributes` are supported but
generally only ``mtu``, ``addresses`` or ``routes`` are used.
Configures VLAN tagging for one VLAN. See :ref:`bonds-with-vlans` for an
example. :ref:`common-attributes` are supported but generally only ``mtu``,
``addresses`` or ``routes`` are used.
Other attributes for ``vlan`` are:
@ -374,9 +379,9 @@ Sets ``VLAN=yes`` and ``PHYSDEV`` to the ``device`` value.
type: linux_bridge
------------------
Configures a `Linux bridge`_. All of the :ref:`common-attributes` can be used
with this type. The ``members`` attribute contains a list of entries for
interfaces to bridge.
Configures a `Linux bridge`_. See :ref:`linux-bridge` for an example. All of
the :ref:`common-attributes` can be used with this type. The ``members``
attribute contains a list of entries for interfaces to bridge.
ifcfg implementation
====================
@ -387,9 +392,9 @@ interface which has ``primary: true`` will be used for the ``MACADDR`` value.
type: linux_bond
----------------
Configures a `Linux bond`_. All of the :ref:`common-attributes` can be used
with this type. The ``members`` attribute contains a list of entries for
interfaces to be bonded.
Configures a `Linux bond`_. See :ref:`bonds-vlans-dpdk` for an example. All
of the :ref:`common-attributes` can be used with this type. The ``members``
attribute contains a list of entries for interfaces to be bonded.
Extra bonding options are specified in the ``bonding_options`` string.
@ -404,10 +409,10 @@ type: ovs_user_bridge
---------------------
Configures an `Open vSwitch`_ bridge where the members are user ports. This
is generally used to set up `DPDK vHost User Ports`_. All of the
:ref:`common-attributes` and :ref:`ovs-attributes` can be used with this
type. The ``members`` attribute usually contains a single ``type:
ovs_dpdk_bond`` entry.
is generally used to set up `DPDK vHost User Ports`_. See
:ref:`bonds-vlans-dpdk` for an example. All of the :ref:`common-attributes`
and :ref:`ovs-attributes` can be used with this type. The ``members``
attribute usually contains a single ``type: ovs_dpdk_bond`` entry.
ifcfg implementation
====================
@ -422,11 +427,11 @@ values depending on the type of the member.
type: ovs_dpdk_bond
-------------------
Configures an `Open vSwitch`_ bond for binding DPDK ports. All of the
:ref:`common-attributes` and :ref:`ovs-attributes` can be used with this
type. The ``members`` attribute contains a list of ``type: ovs_dpdk_port``
ports to be bonded. The value for attribute ``rx_queue`` will determine the
RX queue length.
Configures an `Open vSwitch`_ bond for binding DPDK ports. See
:ref:`bonds-vlans-dpdk` for an example. All of the :ref:`common-attributes`
and :ref:`ovs-attributes` can be used with this type. The ``members``
attribute contains a list of ``type: ovs_dpdk_port`` ports to be bonded. The
value for attribute ``rx_queue`` will determine the RX queue length.
ifcfg implementation
====================
@ -439,11 +444,12 @@ type: ovs_dpdk_port
-------------------
Creates an Open vSwitch DPDK port, usually in the ``members`` of a ``type:
ovs_dpdk_bond`` bond interface. All of the :ref:`common-attributes` and
:ref:`ovs-attributes` can be used with this type. Each port must have a
``members`` list with a single interface entry. A port can have its own
``rx_queue`` specifed. The ``driver`` attribute can override the default
kernel driver module of ``vfio-pci``.
ovs_dpdk_bond`` bond interface. See :ref:`bonds-vlans-dpdk` for an example.
All of the :ref:`common-attributes` and :ref:`ovs-attributes` can be used
with this type. Each port must have a ``members`` list with a single
interface entry. A port can have its own ``rx_queue`` specifed. The
``driver`` attribute can override the default kernel driver module of
``vfio-pci``.
ifcfg implementation
====================

206
doc/source/examples.rst Normal file
View File

@ -0,0 +1,206 @@
======================
Example configurations
======================
.. _multiple-nics:
Multiple NICs
-------------
.. code-block:: yaml
network_config:
- type: interface
name: nic1
mtu: 1500
dns_servers: 8.8.8.8
domain: example.com
routes:
- default: true
next_hop: 198.51.100.1
- ip_netmask: 192.0.2.2/24
next_hop: 203.0.113.254
use_dhcp: false
addresses:
- ip_netmask: 198.18.100.0/15
- type: interface
name: nic2
use_dhcp: true
- type: interface
name: nic3
use_dhcp: false # do not configure this interface
.. _control-plane-bridge:
Control plane bridge
--------------------
.. code-block:: yaml
network_config:
- type: ovs_bridge
name: br-ctlplane
use_dhcp: false
ovs_extra:
- br-set-external-id br-ctlplane bridge-id br-ctlplane
addresses:
- ip_netmask: 192.0.2.2/24
- ip_netmask: 198.51.100.2/24
- ip_netmask: 203.0.113.2/24
dns_servers: 8.8.8.8
domain: example.com
members:
- type: interface
name: nic1
primary: true
mtu: 1450
.. _ovs-bond:
OVS bond
--------
.. code-block:: yaml
network_config:
- type: ovs_bridge
name: br-ex
use_dhcp: true
dns_servers: 8.8.8.8
domain: example.com
members:
- type: ovs_bond
name: bond1
use_dhcp: true
ovs_options: bond_mode=balance-slb
members:
- type: interface
name: nic1
- type: interface
name: nic2
.. _bonds-with-vlans:
Bonds with VLANs and jumbo frames
---------------------------------
.. code-block:: yaml
network_config:
- type: interface
name: nic1
- type: ovs_bridge
name: br-bond
dns_servers: 8.8.8.8
domain: example.com
members:
- type: ovs_bond
name: bond1
mtu: 9000
ovs_options: bond_mode=balance-tcp lacp=active other-config:lacp-fallback-ab=true
members:
- type: interface
name: nic2
mtu: 9000
primary: true
- type: interface
name: nic3
mtu: 9000
- type: vlan
device: bond1
mtu: 9000
vlan_id: 10
addresses:
- ip_netmask: 198.51.200.2/24
- type: vlan
device: bond1
mtu: 9000
vlan_id: 20
addresses:
- ip_netmask: 198.51.100.2/24
.. _linux-bridge:
Linux bridge
------------
.. code-block:: yaml
network_config:
- type: linux_bridge
name: br-ex
addresses:
- ip_netmask: 192.0.2.2/24
dns_servers: 8.8.8.8
domain: example.com
members:
- type: interface
name: nic1
# force the MAC address of the bridge to this interface
primary: true
routes:
- ip_netmask: 0.0.0.0/0
next_hop: 10.0.0.1
default: true
.. _bonds-vlans-dpdk:
Linux bonds, VLANs, and DPDK
----------------------------
.. code-block:: yaml
network_config:
- type: interface
name: nic1
mtu: 1500
use_dhcp: false
addresses:
- ip_netmask: 192.0.2.2/24
routes:
- ip_netmask: 0.0.0.0/0
next_hop: 10.0.0.1
default: true
- type: linux_bond
name: bond_api
mtu: 1500
use_dhcp: false
dns_servers: 8.8.8.8
members:
- type: interface
name: nic2
mtu: 1500
primary: true
- type: interface
name: nic3
mtu: 1500
- type: vlan
device: bond_api
mtu: 1500
vlan_id: 10
addresses:
- ip_netmask: 198.51.200.2/24
- type: vlan
device: bond_api
mtu: 1500
vlan_id: 20
addresses:
- ip_netmask: 198.51.100.2/24
# Used as a provider network with external DHCP #
- type: ovs_user_bridge
name: br-dpdk0
members:
- type: ovs_dpdk_bond
name: dpdkbond0
rx_queue: 1
members:
- type: ovs_dpdk_port
name: dpdk0
members:
- type: interface
name: nic4
- type: ovs_dpdk_port
name: dpdk1
members:
- type: interface
name: nic5

View File

@ -15,6 +15,7 @@ Contents:
installation
usage
config
examples
contributing
Indices and tables