-
Notifications
You must be signed in to change notification settings - Fork 0
Home
NB: the procedure described in this guide makes use of Open vSwitch
The following steps must be executed on the Network Node.
First install the agent:
# apt-get install neutron-lbaas-agent
Then modify the file /etc/neutron/lbaas_agent.ini
:
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
device_driver = neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver
this configuration allows to use the OpenStack implementation based on HAProxy.
Modify the file /etc/neutron/neutron.conf
in the node hosting the neutron-server
service:
service_plugins = neutron.services.loadbalancer.plugin.LoadBalancerPlugin
Modify the Horizon configuration file /etc/openstack-dashboard/local_settings
as follows to enable LBaaS in the dashboard:
'enable_lb': True
Finally restart the services:
# service neutron-server restart
# service neutron-lbaas-agent restart
# service apache2 restart
We have two web servers we want to load balance in Round Robin:
# nova list
+--------------------------------------+---------------------+---------+------------+-------------+------------------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------------------+---------+------------+-------------+------------------------------------------------------+
| 23df32f4-8421-42ba-842c-b87da8b6329c | server-1 | ACTIVE | None | Running | private-net=10.0.0.2; public-net=8.8.8.10 |
| 7decf56a-6817-4763-bd6f-2e175df01272 | server-2 | ACTIVE | None | Running | private-net=10.0.0.6; public-net=8.8.8.11 |
+--------------------------------------+---------------------+---------+------------+-------------+------------------------------------------------------+
# neutron subnet-list
+--------------------------------------+------------------------+-----------------+------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+------------------------+-----------------+------------------------------------------------------+
| 1c9dac7b-1c01-4ea5-95ff-d15e81eb4239 | private-subnet-1 | 10.0.0.0/24 | {"start": "10.0.0.2", "end": "10.0.0.254"} |
| 4642f685-3083-4f08-921d-1fa9ed4b30c9 | public-subnet-1 | 8.8.8.0/24 | {"start": "8.8.8.10", "end": "8.8.8.200"} |
| fba8d585-80c0-4452-9a17-63ffddfc2546 | ext-subnet-1 | 8.8.4.0/24 | {"start": "8.8.4.121", "end": "8.8.4.130"} |
+--------------------------------------+------------------------+-----------------+------------------------------------------------------+
Each of the two servers has 2 NICs, one attached to the public network, the other to the private one. We need load balancing on the public net, so we create the Load Balancer Pool and we associate it to the subnet 8.8.8.0/24
# neutron lb-pool-create --lb-method ROUND_ROBIN --name LBaaSTestPub --protocol HTTP --subnet-id 4642f685-3083-4f08-921d-1fa9ed4b30c9
We create the members of the pool, specifying the public IP addresses of the VMs:
# neutron lb-member-create --address 8.8.8.11 --protocol-port 80 --weight 1 LBaaSTestPub
# neutron lb-member-create --address 8.8.8.10 --protocol-port 80 --weight 1 LBaaSTestPub
We create the health monitor and associate it to the pool:
# neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
# neutron lb-healthmonitor-associate db5a1dfa-0c53-41a7-a803-04e722430a5f LBaaSTestPub
Last, we create the VIP (on the subnet 8.8.8.0/24):
# neutron lb-vip-create --name LBaaSTestPubVIP --protocol-port 80 --protocol HTTP --subnet-id 4642f685-3083-4f08-921d-1fa9ed4b30c9 LBaaSTestPub
To test if the load balancing is working we install and start the Apache web server on the two VMs, inserting into the index.html
file a string containing the hostname of each VM.
From an external client we contact the VIP (8.8.8.13
in this case), repeatedly executing the command "wget :80"
$ wget http://8.8.8.13:80
1968-03-04 19:04:23-- http://8.8.8.13/
Connecting to 8.8.8.13:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 55 [text/html]
Saving to: `index.html'
100%[=====================================================================================================>] 55 --.-K/s in 0s
1968-03-04 19:04:23 (9.22 MB/s) - `index.html' saved [55/55]
We look for the hostname into the index.html
file to verify the round-robin:
$ grep SERVER index*
index.html:<html><body><h1>It works! SERVER-1</h1></body></html>
index.html.1:<html><body><h1>It works! SERVER-2</h1></body></html>
index.html.2:<html><body><h1>It works! SERVER-1</h1></body></html>
index.html.3:<html><body><h1>It works! SERVER-2</h1></body></html>
index.html.4:<html><body><h1>It works! SERVER-1</h1></body></html>