Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Using OVN to replace layer-3 switch

NotificationsYou must be signed in to change notification settings

jcpowermac/homelab-ovn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Motivation

The current switch is a Cisco Catalyst 4006 w/Supervisor V. The chassisis 17 years old and the supervisor almost eight years old. The age plusthe amount of power required to run I decided it was time to go. I havea significantly newer switch that is unfortunately only layer-2. Ofcourse a sane person would say that is good enough.

2. Configuration

Just a fair warning I would never claim to be an expert on networking,Open vSwitch or OVN. To get this to work was mostly working fromother individual’s blog posts, documentation, etc. If something isincorrect please either submit an issue or pull request. With that saidlet’s get started.

2.1. Installation and initial configuration

All the nodes directly participating geneve overlay will be Fedora 27.All the following commands will be based on Fedora. The configuration ofOVN should generally be distribution independent.

2.1.1. OVN northbound database node

First let’s install some packages.

dnf install openvswitch \            openvswitch-ovn-central \            openvswitch-ovn-common \            openvswitch-ovn-host \            python2-openvswitch \            python3-openvswitch -y

If you want to use the container version of Skydive install docker as well. (recommended)

dnf install docker \            docker-compose -y

Then start and enable openvswitch and OVN services.

systemctl start openvswitchsystemctl enable openvswitchsystemctl start ovn-northdsystemctl enable ovn-northd

2.1.2. Hypervisor nodes

Hypervisor in this case is any node that is to be native on OVN. In mycase that is any Fedora physical node including my laptop - at leastwhen its docked.

sudo dnf install openvswitch \                 openvswitch-ovn-common \                 openvswitch-ovn-host

If you want Skydive install docker.

sudo dnf install docker \                 docker-compose -y

Enable and start services, wait to startovn-controller until the nextsection.

systemctl start openvswitchsystemctlenable openvswitchsystemctlenable ovn-controller

2.1.3. Allow north and south bound connections

On the node runningovn-northd execute the following commandsto allow remote connections.

ovn-nbctl set-connection ptcp:6641ovn-sbctl set-connection ptcp:6642ovs-appctl -t ovsdb-server ovsdb-server/add-remote ptcp:6640

2.1.4. Configure ovn-controller on hypervisor nodes

Thedocker how toprovides the commands required to configure the controller. I alsolisted them below.

CENTRAL_IP=172.30.1.10      (1)ENCAP_TYPE=geneveLOCAL_IP=172.30.1.52        (2)ovs-vsctlset open. external_ids:ovn-remote="tcp:${CENTRAL_IP}:6642"ovs-vsctlset open. external_ids:ovn-nb="tcp:${CENTRAL_IP}:6641"ovs-vsctlset open. external_ids:ovn-encap-ip=${LOCAL_IP}ovs-vsctlset open. external_ids:ovn-encap-type="${ENCAP_TYPE}"
  1. IP address of the node runningovn-northd

  2. IP address of current node

After configuration start theovn-controller.

systemctl start ovn-controller

If you runovn-vsctl show you should see at least a new bridgebr-int.

$ sudo ovs-vsctl show90a55931-3706-4d55-9913-4a6e1f4b09e5    Bridge br-int        fail_mode: secure        Port br-int            Interface br-int                type: internal

2.1.5. Gateway node

While I am in the process of migrating to OVN I need access to existingdevices on thelegacy network. It will also be required for devicesthat do not support OVN. Not sure if this is technically the bestway to do this but it works. Additional OVN configuration is required whichwill be listed below.

I made the assumption that IP forwarding would be required so I enabled it.

net.ipv4.ip_forward = 1

Configure thebr-dmz Open vSwitch bridge. This will be in file/etc/sysconfig/network-scripts/ifcfg-br-dmz

DEVICE=br-dmzONBOOT=yesBOOTPROTO=noneTYPE=OVSBridgeDEVICETYPE=ovsOVS_EXTRA="set Open_vSwitch . external-ids:ovn-bridge-mappings=dmz_localnet:br-dmz" (1)
  1. Map thedmz_localnet switch port to thebr-dmz bridge.

Configure the physical interface attached to thelegacy networkand add to thebr-dmz bridge. The IP address will be defined in OVN.This configuration will be in file/etc/sysconfig/network-scripts/ifcfg-enp2s5.

NAME="enp2s5"DEVICE="enp2s5"ONBOOT="yes"NETBOOT="yes"IPV6INIT="no"BOOTPROTO="none"DEFROUTE="no"IPV4_FAILURE_FATAL="no"IPV6_AUTOCONF="no"IPV6_DEFROUTE="no"IPV6_FAILURE_FATAL="no"TYPE=OVSPortDEVICETYPE=ovsOVS_BRIDGE=br-dmz

Finally bring up the bridge and interface.

ifup br-dmzifup enp2s5

2.1.6. Hypervisor node network config

The end goal is to have all network traffic on the overlay so each physicalmachine will have a OVS interface port configure. This configurationfor this example will be in file/etc/sysconfig/network-scripts/ifcfg-bromine.

DEVICE=bromineNAME=bromineTYPE=OVSIntPortDEVICETYPE=ovsOVS_BRIDGE=br-intOVS_EXTRA="set Interface bromine external_ids:iface-id=sw51_bromine"    (1)IPADDR=172.31.51.52NETMASK=255.255.255.0GATEWAY=172.31.51.1DEFROUTE=yesMTU=1500DNS1=10.53.252.123DNS2=10.53.252.246
  1. Theiface-id will be name provided in thelsp-add command.

Bring up the interface but it won’t pass traffic until the logical switch port iscreated.

ifup bromine

2.2. Create OVN switches, routers and static routes

The topology and most of the OVN configuration below were modifications fromthisguide so I recommend reading it for additional information.

2.2.1. Adding Logical Switches

Normal switches:sw50,sw51, andsw52.

Transit switch is between routerr0 and the gateway routergr0. Assumingthis is to allowr0 to be distributed while maintaining a connection to thelocalizedgr0.

desk=sw51transit=tsw0outsw=osw0prod=sw52ose=sw50ovn-nbctl --may-exist ls-add${desk}ovn-nbctl --may-exist ls-add${transit}ovn-nbctl --may-exist ls-add${outsw}ovn-nbctl --may-exist ls-add${prod}ovn-nbctl --may-exist ls-add${ose}

2.2.2. Adding Logical Routers

Only need two routersr0 andgr0.

router=r0gr=gr0ovn-nbctl --may-exist lr-add${router}chassis_uuid=$(ovn-sbctl --bare --columns name find Chassis hostname=ovn-gateway0.virtomation.com)ovn-nbctl create Logical_Router name=${gr} options:chassis=${chassis_uuid}      (1)
  1. The gateway router must be configured on a specific node or chassis.

2.2.3. Adding Logical Router Ports

Create logical router ports with mac and ip addresses for each network.

ovn-nbctl --may-exist lrp-add${router}${router}_${desk} 02:ac:10:1f:33:01 172.31.51.1/24ovn-nbctl --may-exist lrp-add${router}${router}_${prod} 02:ac:10:1f:34:01 172.31.52.1/24ovn-nbctl --may-exist lrp-add${router}${router}_${ose} 02:ac:10:1f:32:01 172.31.50.1/24ovn-nbctl --may-exist lrp-add${router}${router}_${transit} 02:ac:10:1f:ff:02 172.31.255.2/30ovn-nbctl --may-exist lrp-add${gr}${gr}_${transit} 02:ac:10:1f:ff:01 172.31.255.1/30ovn-nbctl --may-exist lrp-add${gr}${gr}_${outsw} 02:ac:10:1f:0c:f6 10.53.12.246/24

2.2.4. Adding Static Routes

Create static routes to enable traffic between networks.

ovn-nbctl lr-route-add${gr} 0.0.0.0/0 10.53.12.1           (1)ovn-nbctl lr-route-add${gr} 10.53.0.0/16 10.53.12.254      (2)ovn-nbctl lr-route-add${gr} 172.31.0.0/16 172.31.255.2     (3)ovn-nbctl lr-route-add${router} 0.0.0.0/0 172.31.255.1     (4)
  1. Static route for internet traffic.

  2. Static route forlegacy networks.

  3. Static route for overlay networks.

  4. Static route for all external networks.

2.2.5. Adding Logical Switch Ports

Create logical switch ports for each router, physical device and the gateway.

# Routerovn-nbctl --may-exist lsp-add${desk}${desk}_${router}ovn-nbctl --may-exist lsp-add${prod}${prod}_${router}ovn-nbctl --may-exist lsp-add${ose}${ose}_${router}ovn-nbctl --may-exist lsp-add${transit}${transit}_${router}ovn-nbctl --may-exist lsp-add${outsw}${outsw}_${gr}ovn-nbctl --may-exist lsp-add${transit}${transit}_${gr}# Physicalovn-nbctl --may-exist lsp-add${desk}${desk}_bromineovn-nbctl --may-exist lsp-add${prod}${prod}_uranium# Gatewayovn-nbctl --may-exist lsp-add${outsw}${outsw}_localnet

2.2.6. Setting Logical Switch Port Configuration

For each port configure the type, allowed address, and appropriate options.

# Routerovn-nbctl lsp-set-type${desk}_${router} routerovn-nbctl lsp-set-addresses${desk}_${router} 02:ac:10:1f:33:01ovn-nbctl lsp-set-options${desk}_${router} router-port=${router}_${desk}ovn-nbctl lsp-set-type${prod}_${router} routerovn-nbctl lsp-set-addresses${prod}_${router} 02:ac:10:1f:34:01ovn-nbctl lsp-set-options${prod}_${router} router-port=${router}_${prod}ovn-nbctl lsp-set-type${ose}_${router} routerovn-nbctl lsp-set-addresses${ose}_${router} 02:ac:10:1f:32:01ovn-nbctl lsp-set-options${ose}_${router} router-port=${router}_${ose}ovn-nbctl lsp-set-type${outsw}_${gr} routerovn-nbctl lsp-set-addresses${outsw}_${gr} 02:ac:10:1f:0c:f6ovn-nbctl lsp-set-options${outsw}_${gr} router-port=${gr}_${outsw}ovn-nbctl lsp-set-type${transit}_${gr} routerovn-nbctl lsp-set-addresses${transit}_${gr} 02:ac:10:1f:ff:01ovn-nbctl lsp-set-options${transit}_${gr} router-port=${gr}_${transit}ovn-nbctl lsp-set-type${transit}_${router} routerovn-nbctl lsp-set-addresses${transit}_${router} 02:ac:10:1f:ff:02ovn-nbctl lsp-set-options${transit}_${router} router-port=${router}_${transit}# Gatewayovn-nbctl lsp-set-type${outsw}_localnet localnetovn-nbctl lsp-set-addresses${outsw}_localnet unknownovn-nbctl lsp-set-options${outsw}_localnet network_name=dmz_localnet# Physicalovn-nbctl lsp-set-addresses${desk}_bromine unknownovn-nbctl lsp-set-addresses${prod}_uranium unknown

3. Virtualization

After getting a few physical machines up and running on OVN the next stepwas my real hypervisor nodes. This was more of a challenge than Ioriginally thought it was going to be. I started by reviewing thisblog post: Using OVN with KVM and Libvirtwhich certainly provided valuable insight. Though being a lazy programmer there had tobe a better way -libvirt hooks.

3.1. Installing the libvirt qemu hook

Provided in this repository is aqemuhook for OVN. It adds and removes the switch port when the machine is started or stopped.The configuration for theovn-northd node and the switch name is stored inthe virtual machines metadata.

First some prerequisites.

dnf install git -ypip install ovsdbappgit clone https://github.com/jcpowermac/homelab-ovn

If the directory doesn’t exist (which it didn’t on my hypervisor) create it.

mkdir -p /etc/libvirt/hooks/cp homelab-ovn/libvirt-hook/qemu /etc/libvirt/hooks/chmod 744 /etc/libvirt/hooks/qemu

After the hook is available libvirtd needs to be restarted.

systemctl restart libvirtd

3.2. Add OVN metadata to virtual machine

Thevirt-install command is an example the--network option that must be used to connect avirtual machine to a specific logical switch. Thevirsh metadata command below adds metadatato a defined virtual machine. This commandmust be written exactly as below for theqemu hook tofunction properly.

virt-install --import --name$vm --memory 8192 --vcpus 2 \         --graphics none --console pty,target_type=serial \             --os-type linux --os-variant rhel7.0 --noautoconsole \ --disk path=/instances/$vm.qcow2,format=qcow2,bus=virtio \ --network bridge=br-int,virtualport_type=openvswitch           (1)virsh metadata$vm --uri ovs \                   --key ovn \               --set'<parameters northd="172.30.1.10" switch="sw50"/>'     (2)
  1. The virtual machine must attach to thebr-int bridge and have avirtualport_type ofopenvswitch.

  2. The parameters are farily simple,northd is the ip address ofovn-northd node andswitch is where the virtual machine should be connected.

4. Visualizations

Sometimes its better to have a picture or two.

4.1. Skydive

As I suggested above runningSkydive is a good idea.At least then you have a visual representation of the interfaces and bridges that are used.

Skydive

4.2. OVN topology using Jupyter

Included in this repo is aJupyter notebook. It currently displays logical routers, switches, ports, and networks on the edge.

OVN

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp