Load balancer configuration

This procedure outlines the steps to configure a load-balancer for an existing tenant in MidoNet. In the example, we will use:

  • VIP: 203.0.113.2
  • Pool Members: 192.168.100.100, 192.168.100.101

Let’s start by determining the list of routers we have available in our MidoNet deployment:

midonet> list router
router router0 name Edge Router state up
router router1 name Tenant Router state up infilter chain0 outfilter chain1

As you can see, your Tenant Router where you are going to create a load balancer is router1.

[Important]Important

In MidoNet, routers have inbound and outbound filters. If the load balancer on a router balances traffic, these filters will be skipped. When using MidoNet with OpenStack, these filters usually only contain NAT rules that are irrelevant to load-balanced traffic, but this is worth taking into account if you are adding custom rules to the router’s filters.

  1. Create a load balancer and assign it to the Tenant Router.

    midonet> load-balancer create
    lb0
    midonet> router router1 set load-balancer lb0

    The load balancer assigned to the router will act on traffic flowing through that router.

  2. Create a pool to which target back-end servers will be assigned.

    midonet> load-balancer lb0 create pool lb-method ROUND_ROBIN
    lb0:pool0
    midonet> load-balancer lb0 pool pool0 show
    pool pool0 load-balancer lb0 lb-method ROUND_ROBIN state up
  3. Next, add target back-end servers to the pool you just created.

    midonet> load-balancer lb0 pool pool0 create member address 192.168.100.100 protocol-port 80
    lb0:pool0:pm0
    midonet> load-balancer lb0 pool pool0 create member address 192.168.100.101 protocol-port 80
    lb0:pool0:pm1
    midonet> load-balancer lb0 pool pool0 member pm0 show
    pm pm0 address 192.168.100.1 protocol-port 80 weight 0 state up

    For each back-end server you must add its IP address and port to the pool.

  4. Create a virtual IP address (VIP) and port, then assign it to the pool against which load balancing will be performed (lb0:pool0). Typically, a VIP is an IP address from the public IP space.

    midonet> load-balancer lb0 pool pool0 list vip
    midonet> load-balancer lb0 pool pool0 create vip address 203.0.113.2 persistence SOURCE_IP protocol-port 8080
    lb0:pool0:vip0
    midonet> load-balancer lb0 pool pool0 vip vip0 show
    vip vip0 load-balancer lb0 address 203.0.113.2 protocol-port 8080 persistence SOURCE_IP state up
    [Note]Note

    Above example uses sticky source IP address persistence, read more about it in the section called “Sticky Source IP”.

  5. Lastly, you must add a routing rule on the Edge Router (router0) so that a packet sent to the VIP is able to find its way to the Tenant Router where the LB is defined.

    1. First, identify the ports on the Edge Router, using the router router0 list port command, like so:

      midonet> router router0 list port
      port port0 device router0 state up mac 02:c2:0f:b0:f2:68 addresses 100.100.100.1/30
      port port1 device router0 state up mac 02:cb:3d:85:89:2a addresses 172.168.0.1/16
      port port2 device router0 state up mac 02:46:87:89:49:41 addresses 200.200.200.1/24 peer bridge0:port0
      port port3 device router0 state up mac 02:6b:9f:0d:c4:a8 addresses 169.254.255.1/30 peer router1:port0
      ...

      Identify the port on the Edge Router that is used to route traffic to the Tenant Router (router1). In this example, we see port3 on device router0 is peered to the Tenant Router port (router1:port0).

    2. Next, add the route to the Edge Router to send traffic to router0:port3 (local port on Edge Router).

      midonet> router router0 add route dst 203.0.113.2/32 src 0.0.0.0/0 type normal port router0:port3
      router0:route11

      This rule matches any incoming traffic (src 0.0.0.0/0) to the Edge Router that is sent to the VIP (dst 203.0.113.2/32) and sends it out the desired Edge Router port (router0:port3).

To delete an existing load balancer, run the following command:

midonet> load-balancer list
lb lb0 state up
midonet> load-balancer lb0 delete
Questions? Discuss on Mailing Lists or Chat.
Found an error? Report a bug.


loading table of contents...