Examples

Linux bonding

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: bond
spec:
  desiredState:
    interfaces:
    - name: bond0
      type: bond
      state: up
      copy-mac-from: eth1
      ipv4:
        dhcp: true
        enabled: true
      link-aggregation:
        mode: balance-rr
        options:
          miimon: '140'
        port:
        - eth1
        - eth2

Linux bonding with VLAN

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: bond-vlan
spec:
  desiredState:
    interfaces:
    - name: bond0
      type: bond
      state: up
      ipv4:
        dhcp: true
        enabled: true
      link-aggregation:
        mode: balance-rr
        options:
          miimon: '140'
        port:
        - eth1
        - eth2
    - name: bond0.102
      type: vlan
      state: up
      ipv4:
        dhcp: true
        enabled: true
      vlan:
        base-iface: bond0
        id: 102

Detach bridge port and restore eth configuration

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: detach-bridge-port-and-restore-eth
spec:
  desiredState:
    interfaces:
    - name: br1
      type: linux-bridge
      state: absent
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        dhcp: true
        enabled: true

DHCP

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: dhcp
spec:
  desiredState:
    interfaces:
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        dhcp: true
        enabled: true

DNS

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: dns
spec:
  desiredState:
    dns-resolver:
      config:
        search:
        - example.com
        - example.org
        server:
        - 8.8.8.8
        - 2001:4860:4860::8888
    interfaces:
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        auto-dns: false
        dhcp: true
        enabled: true
      ipv6:
        auto-dns: false
        dhcp: true
        enabled: true

Ethernet

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: ethernet
spec:
  desiredState:
    interfaces:
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        dhcp: true
        enabled: true

Linux bridge

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: linux-bridge
spec:
  desiredState:
    interfaces:
    - name: br1
      description: Linux bridge with eth1 as a port
      type: linux-bridge
      state: up
      ipv4:
        dhcp: true
        enabled: true
      bridge:
        options:
          stp:
            enabled: false
        port:
        - name: eth1


## Linux bridge with custom VLAN filtering

```yaml
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: linux-bridge-vlan
spec:
  desiredState:
    interfaces:
      - name: br1
        description: Linux bridge with eth1 as a port with custom vlan configuration
        type: linux-bridge
        state: up
        ipv4:
          dhcp: true
          enabled: true
        bridge:
          options:
            stp:
              enabled: false
          port:
            - name: eth1
              vlan:
                mode: trunk
                trunk-tags:
                  - id: 101
                  - id-range:
                      max: 500
                      min: 200
                tag: 100
                enable-native: true

Open vSwitch bridge interface

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: ovs-bridge-iface
spec:
  desiredState:
    interfaces:
      - name: ovs0
        type: ovs-interface
        state: up
        ipv4:
          dhcp: true
          enabled: true
      - name: br1
        description: ovs bridge with eth1 as a port and ovs0 as an internal interface
        type: ovs-bridge
        state: up
        bridge:
          options:
            stp: true
          port:
            - name: eth1
            - name: ovs0

Open vSwitch bridge

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: ovs-bridge
spec:
  desiredState:
    interfaces:
    - name: br1
      description: ovs bridge with eth1 as a port
      type: ovs-bridge
      state: up
      bridge:
        options:
          stp: false
        port:
        - name: eth1

Routes

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: route
spec:
  nodeSelector:
    kubernetes.io/hostname: node02
  desiredState:
    interfaces:
      - name: eth1
        type: ethernet
        state: up
        ipv4:
          address:
          - ip: 192.0.2.251
            prefix-length: 24
          dhcp: false
          enabled: true
    routes:
      config:
      - destination: 198.51.100.0/24
        metric: 150
        next-hop-address: 192.0.2.2
        next-hop-interface: eth1
        table-id: 254

Static IP

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: static-ip
spec:
  nodeSelector:
    kubernetes.io/hostname: node02
  desiredState:
    interfaces:
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        address:
        - ip: 10.244.0.2
          prefix-length: 24
        dhcp: false
        enabled: true

VLAN

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: vlan
spec:
  desiredState:
    interfaces:
    - name: eth1.102
      type: vlan
      state: up
      vlan:
        id: 102
        base-iface: eth1
      ipv4:
        dhcp: true
        enabled: true

VRF

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: vrf
spec:
  desiredState:
    interfaces:
    - name: vrf102
      state: up
      type: vrf
      vrf:
        port:
        - eth1
        route-table-id: 102
    - ipv4:
        address:
        - ip: 192.0.2.251
          prefix-length: 24
        dhcp: false
        enabled: true
      name: eth1
      state: up
      type: ethernet
    routes:
      config:
      - destination: 198.51.100.0/24
        metric: 150
        next-hop-address: 192.0.2.1
        next-hop-interface: eth1
        table-id: 102
  nodeSelector:
    kubernetes.io/hostname: node01

Worker selector

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: worker-selector
spec:
  # Note that workers on Kubernetes are not labeled by default
  nodeSelector:
    node-role.kubernetes.io/worker: ""
  desiredState:
    interfaces:
    - name: eth1
      type: ethernet
      state: up
      ipv4:
        dhcp: true
        enabled: true