Installing LBaaS

Run following command on controller node to install the required components (HAProxy and LBaaS package).

root@controller:~#  yum install haproxy openstack-neutron-lbaas

 

Configuring  LBaaS

Edit the file – /etc/neutron/neutron.conf

service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_plugins = router,lbaas

 

Edit the file – /etc/neutron/neutron_lbaas.conf

service_provider=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default

 

Edit the file – /etc/neutron/lbaas_agent.ini

[DEFAULT]
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
device_driver = neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver

 

Edit the file – /etc/openstack-dashboard/local_settings.py

OPENSTACK_NEUTRON_NETWORK = {


….

‘enable_lb’: True,

 

Restart the services

# service neutron-server restart
# service neutron-lbaas-agent restart

 

Now you will be able to see “Load Balancers” on OpenStack Dashboard webpage under Project -> Network Menu.

 

Creating a ROUND_ROBIN Load Balancer between two instances

Get the details of running Instances

root@controller:~# nova list
+--------------------------------------+------+--------+------------+-------------+---------------------+
| ID                                   | Name | Status | Task State | Power State | Networks            |
+--------------------------------------+------+--------+------------+-------------+---------------------+
| a2e61f7a-f701-4e18-a4e4-3240c6e9b946 | lb1  | ACTIVE | -          | Running     | private=10.0.1.1    |
| 4cbd5376-6d32-414c-9272-2c22002d1468 | lb2  | ACTIVE | -          | Running     | private=10.0.1.2    |
+--------------------------------------+------+--------+------------+-------------+---------------------+

I have 2 Instances running apache2 server on lb1 & lb2

VM Name -> VM ID -> Private Network IP

lb1->a2e61f7a-f701-4e18-a4e4-3240c6e9b946->10.0.1.1

lb2->4cbd5376-6d32-414c-9272-2c22002d1468->10.0.1.2

 

Get network list

root@controller:~# neutron net-list
+--------------------------------------+---------+--------------------------------------------------------+
| id                                   | name    | subnets                                                |
+--------------------------------------+---------+--------------------------------------------------------+
| 297c004b-435b-4741-b2f0-53a011403f61 | lb_net1 | e94e1b6c-aff2-45f2-a13c-a41593125a2d 10.0.2.0/24       |
| 7645e3f6-444d-4e4b-ad4f-a9cf49683b2d | public  | f72e1955-b32f-4d49-8a6f-1833d6e2e1f3 10.0.16.0/26      | 
|                                      |         | 219765fc-be8d-4ef5-90a2-6c7ef2c961e9 10.0.22.0/26      |
| e232d0c0-4363-4b39-b88a-949e177f058a | private | a0cf224b-1f42-4650-b219-b9320d4ea06f 10.0.1.0/24       |
+--------------------------------------+---------+--------------------------------------------------------+

 

Get subnet list

root@controller:~# neutron subnet-list
+--------------------------------------+------------+-------------------+------------------------------------------------------+
| id                                   | name       | cidr              | allocation_pools                                     |
+--------------------------------------+------------+-------------------+------------------------------------------------------+
| e94e1b6c-aff2-45f2-a13c-a41593125a2d | lb_subnet1 | 10.0.2.0/24       | {"start": "10.0.2.1", "end": "10.0.2.80"}            |
| f72e1955-b32f-4d49-8a6f-1833d6e2e1f3 | public1    | 10.0.16.0/26      | {"start": "10.0.16.1", "end": "10.0.16.60"}          |
| 219765fc-be8d-4ef5-90a2-6c7ef2c961e9 | public     | 10.0.22.0/26      | {"start": "10.0.22.1", "end": "10.0.22.60"}          |
|                                      |            |                   |
| a0cf224b-1f42-4650-b219-b9320d4ea06f | private    | 10.0.1.0/24       | {"start": "10.0.1.1", "end": "10.0.1.80"}            |
+--------------------------------------+------------+-------------------+------------------------------------------------------+

 

Create Pool

root@controller:~# neutron lb-pool-create --name http-pool --lb-method ROUND_ROBIN --protocol HTTP --subnet-id a0cf224b-1f42-4650-b219-b9320d4ea06f
Created a new pool:
+------------------------+--------------------------------------+
| Field                  | Value                                |
+------------------------+--------------------------------------+
| admin_state_up         | True                                 |
| description            |                                      |
| health_monitors        |                                      |
| health_monitors_status |                                      |
| id                     | 2cef1601-dfbe-4e02-beaf-71c303a3009f |
| lb_method              | ROUND_ROBIN                          |
| members                |                                      |
| name                   | http-pool                            |
| protocol               | HTTP                                 |
| provider               | haproxy                              |
| status                 | PENDING_CREATE                       |
| status_description     |                                      |
| subnet_id              | a0cf224b-1f42-4650-b219-b9320d4ea06f |
| tenant_id              | 4664cf886f57480d9e3a1af4bf8a3a65     |
| vip_id                 |                                      |
+------------------------+--------------------------------------+

 

Check the pool status

root@controller:~# neutron lb-pool-list
+--------------------------------------+-----------+----------+-------------+----------+----------------+--------+
| id                                   | name      | provider | lb_method   | protocol | admin_state_up | status |
+--------------------------------------+-----------+----------+-------------+----------+----------------+--------+
| 2cef1601-dfbe-4e02-beaf-71c303a3009f | http-pool | haproxy  | ROUND_ROBIN | HTTP     | True           | ACTIVE |
+--------------------------------------+-----------+----------+-------------+----------+----------------+--------+

 

Add members to pool

root@controller:~# neutron lb-member-create --address 10.0.1.1 --protocol-port 80 http-pool
Created a new member:
+--------------------+--------------------------------------+
| Field              | Value                                |
+--------------------+--------------------------------------+
| address            | 10.0.1.1                             |
| admin_state_up     | True                                 |
| id                 | 4e1a4853-9b98-4571-a306-9daa1ca9f08b |
| pool_id            | 2cef1601-dfbe-4e02-beaf-71c303a3009f |
| protocol_port      | 80                                   |
| status             | PENDING_CREATE                       |
| status_description |                                      |
| tenant_id          | 4664cf886f57480d9e3a1af4bf8a3a65     |
| weight             | 1                                    |
+--------------------+--------------------------------------+

root@controller:~# neutron lb-member-create --address 10.0.1.2 --protocol-port 80 http-pool
Created a new member:
+--------------------+--------------------------------------+
| Field              | Value                                |
+--------------------+--------------------------------------+
| admin_state_up     | True                                 |
| id                 | ed53de4b-cad7-417f-82f3-4777f6bc831b |
| pool_id            | 2cef1601-dfbe-4e02-beaf-71c303a3009f |
| protocol_port      | 80                                   |
| status             | PENDING_CREATE                       |
| status_description |                                      |
| tenant_id          | 4664cf886f57480d9e3a1af4bf8a3a65     |
| weight             | 1                                    |
+--------------------+--------------------------------------+

 

Check the members are added and ACTIVE

root@controller:~# neutron lb-member-list --sort-key address --sort-dir asc
+--------------------------------------+-------------+---------------+--------+----------------+--------+
| id                                   | address     | protocol_port | weight | admin_state_up | status |
+--------------------------------------+-------------+---------------+--------+----------------+--------+
| 4e1a4853-9b98-4571-a306-9daa1ca9f08b | 10.0.1.1    |            80 |      1 | True           | ACTIVE |
| ed53de4b-cad7-417f-82f3-4777f6bc831b | 10.0.1.2    |            80 |      1 | True           | ACTIVE |
+--------------------------------------+-------------+---------------+--------+----------------+--------+

 

Create Health Monitor

root@controller:~# neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3
Created a new health_monitor:
+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| admin_state_up | True                                 |
| delay          | 3                                    |
| expected_codes | 200                                  |
| http_method    | GET                                  |
| id             | 479cd68a-fe2d-4234-89d8-13b1c26291d1 |
| max_retries    | 3                                    |
| pools          |                                      |
| tenant_id      | 4664cf886f57480d9e3a1af4bf8a3a65     |
| timeout        | 3                                    |
| type           | HTTP                                 |
| url_path       | /                                    |
+----------------+--------------------------------------+

 

Check the status of health monitor

root@controller:~# neutron lb-healthmonitor-list
+--------------------------------------+------+----------------+
| id                                   | type | admin_state_up |
+--------------------------------------+------+----------------+
| 479cd68a-fe2d-4234-89d8-13b1c26291d1 | HTTP | True           |
+--------------------------------------+------+----------------+

 

Health Monitor ID is  479cd68a-fe2d-4234-89d8-13b1c26291d1

Associate Health Monitor to Pool

root@controller:~# neutron lb-healthmonitor-associate 479cd68a-fe2d-4234-89d8-13b1c26291d1 http-pool
Associated health monitor 479cd68a-fe2d-4234-89d8-13b1c26291d1

 

Create a virtual IP for pool with HTTP port

root@controller:~# neutron lb-vip-create --name  http-vip --protocol-port 80 --protocol HTTP --subnet-id a0cf224b-1f42-4650-b219-b9320d4ea06f http-pool
Created a new vip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 10.0.1.4                             |
| admin_state_up      | True                                 |
| connection_limit    | -1                                   |
| description         |                                      |
| id                  | 8970ebd2-a19d-4650-b6ee-6e18985e823a |
| name                | http-vip                             |
| pool_id             | 2cef1601-dfbe-4e02-beaf-71c303a3009f |
| port_id             | 581babfc-e596-4cae-93a6-3349ed4e5577 |
| protocol            | HTTP                                 |
| protocol_port       | 80                                   |
| session_persistence |                                      |
| status              | PENDING_CREATE                       |
| status_description  |                                      |
| subnet_id           | a0cf224b-1f42-4650-b219-b9320d4ea06f |
| tenant_id           | 4664cf886f57480d9e3a1af4bf8a3a65     |
+---------------------+--------------------------------------+

 

Check VIP status

root@controller:~# neutron lb-vip-list
+--------------------------------------+----------+-------------+----------+----------------+--------+
| id                                   | name     | address     | protocol | admin_state_up | status |
+--------------------------------------+----------+-------------+----------+----------------+--------+
| 8970ebd2-a19d-4650-b6ee-6e18985e823a | http-vip | 10.0.1.4    | HTTP     | True           | ACTIVE |
+--------------------------------------+----------+-------------+----------+----------------+--------+

 

Associate a floating IP to VIP

Add a floating IP from external net

root@controller:~# neutron floatingip-create public
Created a new floating ip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    |                                      |
| floating_ip_address | 10.0.22.3                            |
| floating_network_id | 7645e3f6-444d-4e4b-ad4f-a9cf49683b2d |
| id                  | 167114de-feb7-4746-b3d3-4e9c801b7375 |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 4664cf886f57480d9e3a1af4bf8a3a65     |
+---------------------+--------------------------------------+

 

Get the Port ID, Floating IP ID and associate Floating IP to Port ID of VIP

root@controller:~# neutron floatingip-associate 167114de-feb7-4746-b3d3-4e9c801b7375 581babfc-e596-4cae-93a6-3349ed4e5577
Associated floating IP 167114de-feb7-4746-b3d3-4e9c801b7375

 

Check the Floating IP list to verify

root@controller:~# neutron floatingip-list --sort-key floating_ip_address --sort-dir asc
+--------------------------------------+------------------+---------------------+--------------------------------------+
| id                                   | fixed_ip_address | floating_ip_address | port_id                              |
+--------------------------------------+------------------+---------------------+--------------------------------------+
| 03bc56f2-c78a-4b90-919c-7c89dec548d7 |                  | 10.0.22.2           |                                      |
| 0e5ce334-18e6-4389-8faa-666fbb86e1bc |                  | 10.0.22.5           |                                      |
| 12b33a39-89b1-423f-90f9-ad3d7617d536 |                  | 10.0.22.7           |                                      |
| 14992ab1-19d1-4271-bd6b-86d52bb1a2d3 |                  | 10.0.22.9           |                                      |
| 167114de-feb7-4746-b3d3-4e9c801b7375 | 10.0.1.4         | 10.0.22.3           | 581babfc-e596-4cae-93a6-3349ed4e5577 |
| 314fa02e-9ae6-42b1-9c15-11202aff8489 |                  | 10.0.16.4           |                                      |
| 888b1e36-5fc9-4aa1-995a-cb6e6834a1e3 |                  | 10.0.16.6           |                                      |
| 8fc7e5f1-4a08-4ce3-b17a-20212348051f |                  | 10.0.22.9           |                                      |
+--------------------------------------+------------------+---------------------+--------------------------------------+

 

Now check in browser http://<associated_floating_ip/

Advertisements