Ubuntu 18.04
Sponsored Link

OpenStack Stein : Neutron LBaaS V22019/04/12

 
Configure Neutron LBaaS (Load-Balancer-as-a-Service) V2.
This example is based on the environment like follows.
Before settings, Configure basic settings of Control Node, Network Node, Compute Node, and also this example is based on the Neutron VXLAN Network like here.
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |        L2 Agent       |   |        Libvirt        |
|  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
|  Nova API             |   |      LBaaSV2 Agent    |   |      LBaaSV2 Agent    |
|  Neutron Server       |   |                       |   |                       |
|  Metadata Agent       |   |                       |   |                       |
+-----------------------+   +-----------+-----------+   +-----------------------+
                                    eth1|(UP with no IP)

[1] On Control Node, Change settings like follows.
root@dlp ~(keystone)#
apt -y install neutron-lbaasv2-agent
root@dlp ~(keystone)#
vi /etc/neutron/neutron.conf
# add to [service_plugins]

service_plugins = router
,lbaasv2
root@dlp ~(keystone)#
vi /etc/neutron/neutron_lbaas.conf
# line 207: add

[service_providers]
service_provider = LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default

root@dlp ~(keystone)#
vi /etc/neutron/lbaas_agent.ini
# add into [DEFAULT] section

[DEFAULT]
interface_driver = linuxbridge
root@dlp ~(keystone)#
su -s /bin/bash neutron -c "neutron-db-manage --subproject neutron-lbaas --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head"

root@dlp ~(keystone)#
systemctl restart neutron-server

[2] On Network Node and Compute Node, Change settings like follows.
root@network:~#
apt -y install neutron-lbaasv2-agent haproxy
root@network:~#
vi /etc/neutron/neutron.conf
# add to [service_plugins]

service_plugins = router
,lbaasv2
root@network:~#
vi /etc/neutron/neutron_lbaas.conf
# line 207: add

[service_providers]
service_provider = LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default

root@network:~#
vi /etc/neutron/lbaas_agent.ini
# add into [DEFAULT] section

[DEFAULT]
interface_driver = linuxbridge
root@network:~#
systemctl restart neutron-lbaasv2-agent

root@network:~#
systemctl enable neutron-lbaasv2-agent

[3] On Control Node, confirm Neutron Services, then it's OK if Loadbalancerv2 agent are UP state.
root@dlp ~(keystone)#
openstack network agent list

+--------------------------------------+----------------------+-------------------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type           | Host              | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+----------------------+-------------------+-------------------+-------+-------+---------------------------+
| 0904751e-e3f0-412f-8d4c-8aa901fb81b4 | Linux bridge agent   | node01.srv.world  | None              | :-)   | UP    | neutron-linuxbridge-agent |
| 5086bf0b-f03e-4b37-9102-4ad2f1253c25 | Loadbalancerv2 agent | node01.srv.world  | None              | :-)   | UP    | neutron-lbaasv2-agent     |
| 5bba28da-407f-49f4-9c68-9e2897f43dcb | Loadbalancerv2 agent | dlp.srv.world     | None              | :-)   | UP    | neutron-lbaasv2-agent     |
| 73c24b54-a68c-4592-b1c2-4befb9b11612 | L3 agent             | network.srv.world | nova              | :-)   | UP    | neutron-l3-agent          |
| a790f336-df80-445b-b449-47af9e272dbd | Loadbalancerv2 agent | network.srv.world | None              | :-)   | UP    | neutron-lbaasv2-agent     |
| b54fd4ab-d61d-4509-8a55-9f0bce50c3eb | DHCP agent           | network.srv.world | nova              | :-)   | UP    | neutron-dhcp-agent        |
| be4a605d-8126-431a-a55d-bc82d11ba57b | Metadata agent       | network.srv.world | None              | :-)   | UP    | neutron-metadata-agent    |
| c1337f30-786c-4e73-9910-6f16630e811b | Metadata agent       | dlp.srv.world     | None              | :-)   | UP    | neutron-metadata-agent    |
| d4ed35e2-43ae-4f68-bde5-f466898dbcda | Linux bridge agent   | network.srv.world | None              | :-)   | UP    | neutron-linuxbridge-agent |
+--------------------------------------+----------------------+-------------------+-------------------+-------+-------+---------------------------+
[4] Login with any Openstack user and Create Virtual Load-Balancer.
# make sure current network environment

ubuntu@dlp ~(keystone)$
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 4ac44922-6ee9-4f99-9901-06cd69bcb64b | ext_net | 19f83d21-e41f-4e96-8da1-84bfba298fc7 |
| 596c0921-5acb-42e1-8b44-ff549c30cded | int_net | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 |
+--------------------------------------+---------+--------------------------------------+
ubuntu@dlp ~(keystone)$
openstack subnet list

+--------------------------------------+---------+--------------------------------------+------------------+
| ID                                   | Name    | Network                              | Subnet           |
+--------------------------------------+---------+--------------------------------------+------------------+
| d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 | subnet1 | 596c0921-5acb-42e1-8b44-ff549c30cded | 192.168.100.0/24 |
+--------------------------------------+---------+--------------------------------------+------------------+

# create a LB [lb01] in [subnet1]

ubuntu@dlp ~(keystone)$
neutron lbaas-loadbalancer-create --name lb01 subnet1

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| description         |                                      |
| id                  | 73e22025-12cb-41aa-bfd7-2f9a3f74fd5d |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| provider            | haproxy                              |
| provisioning_status | PENDING_CREATE                       |
| tenant_id           | ff03eefa265b423aa3375acb46a8e4e0     |
| vip_address         | 192.168.100.79                       |
| vip_port_id         | d5d89d1e-c47b-4e74-b5d8-9809f46050fb |
| vip_subnet_id       | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 |
+---------------------+--------------------------------------+

# create a security group for [lb01] and allow ports you'd like to set load-balancing (example is 80 port)

ubuntu@dlp ~(keystone)$
openstack security group create lbaasv2

ubuntu@dlp ~(keystone)$
openstack security group rule create --protocol icmp --ingress lbaasv2

ubuntu@dlp ~(keystone)$
openstack security group rule create --protocol tcp --dst-port 80:80 lbaasv2
# apply security group [lbaasv2] to [lb01]'s [vip_port_id]

ubuntu@dlp ~(keystone)$
openstack port set --security-group lbaasv2 d5d89d1e-c47b-4e74-b5d8-9809f46050fb
# create a listener for a port you'd like to set load-balancing (example is 80 port)

ubuntu@dlp ~(keystone)$
neutron lbaas-listener-create --name lb01-http --loadbalancer lb01 --protocol HTTP --protocol-port 80

+---------------------------+------------------------------------------------+
| Field                     | Value                                          |
+---------------------------+------------------------------------------------+
| admin_state_up            | True                                           |
| connection_limit          | -1                                             |
| default_pool_id           |                                                |
| default_tls_container_ref |                                                |
| description               |                                                |
| id                        | a68885c0-44dc-4e17-a725-ae1464871c86           |
| loadbalancers             | {"id": "73e22025-12cb-41aa-bfd7-2f9a3f74fd5d"} |
| name                      | lb01-http                                      |
| protocol                  | HTTP                                           |
| protocol_port             | 80                                             |
| sni_container_refs        |                                                |
| tenant_id                 | ff03eefa265b423aa3375acb46a8e4e0               |
+---------------------------+------------------------------------------------+

# create a pool [lb01-http-pool] with ROUND_ROBIN Algorithm for the listener created above

ubuntu@dlp ~(keystone)$
neutron lbaas-pool-create --name lb01-http-pool --lb-algorithm ROUND_ROBIN --listener lb01-http --protocol HTTP

+---------------------+------------------------------------------------+
| Field               | Value                                          |
+---------------------+------------------------------------------------+
| admin_state_up      | True                                           |
| description         |                                                |
| healthmonitor_id    |                                                |
| id                  | 94ab097d-29bd-4e34-b659-bd7b1aa3b92d           |
| lb_algorithm        | ROUND_ROBIN                                    |
| listeners           | {"id": "a68885c0-44dc-4e17-a725-ae1464871c86"} |
| loadbalancers       | {"id": "73e22025-12cb-41aa-bfd7-2f9a3f74fd5d"} |
| members             |                                                |
| name                | lb01-http-pool                                 |
| protocol            | HTTP                                           |
| session_persistence |                                                |
| tenant_id           | ff03eefa265b423aa3375acb46a8e4e0               |
+---------------------+------------------------------------------------+
[5] To add members to the pool of listener, it's OK all.
# instances which Apache httpd are running

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-------------------------+------------+----------+
| ID                                   | Name        | Status | Networks                | Image      | Flavor   |
+--------------------------------------+-------------+--------+-------------------------+------------+----------+
| aaa27b11-7866-4bbc-9ec6-f7e7616a1cd9 | WebServer02 | ACTIVE | int_net=192.168.100.230 | Ubuntu1804 | m1.small |
| 475da96e-f681-4a1e-9cde-26b61a7fb7e5 | WebServer01 | ACTIVE | int_net=192.168.100.41  | Ubuntu1804 | m1.small |
+--------------------------------------+-------------+--------+-------------------------+------------+----------+

# add to the pool as a member

ubuntu@dlp ~(keystone)$
neutron lbaas-member-create --name lb01-member-01 --subnet subnet1 --address 192.168.100.41 --protocol-port 80 lb01-http-pool

+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| address        | 192.168.100.41                       |
| admin_state_up | True                                 |
| id             | 31eb19db-dc6c-479f-8e02-d2063c2dfaf0 |
| name           | lb01-member-01                       |
| protocol_port  | 80                                   |
| subnet_id      | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 |
| tenant_id      | ff03eefa265b423aa3375acb46a8e4e0     |
| weight         | 1                                    |
+----------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
neutron lbaas-member-create --name lb01-member-02 --subnet subnet1 --address 192.168.100.230 --protocol-port 80 lb01-http-pool

+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| address        | 192.168.100.230                      |
| admin_state_up | True                                 |
| id             | 7a9bc781-4c50-47d5-b240-472162b2ff4c |
| name           | lb01-member-02                       |
| protocol_port  | 80                                   |
| subnet_id      | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 |
| tenant_id      | ff03eefa265b423aa3375acb46a8e4e0     |
| weight         | 1                                    |
+----------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
neutron lbaas-member-list lb01-http-pool

+--------------------------------------+----------------+-----------------+---------------+--------+--------------------------------------+----------------+
| id                                   | name           | address         | protocol_port | weight | subnet_id                            | admin_state_up |
+--------------------------------------+----------------+-----------------+---------------+--------+--------------------------------------+----------------+
| 7a9bc781-4c50-47d5-b240-472162b2ff4c | lb01-member-02 | 192.168.100.230 |            80 |      1 | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 | True           |
| 31eb19db-dc6c-479f-8e02-d2063c2dfaf0 | lb01-member-01 | 192.168.100.41  |            80 |      1 | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72 | True           |
+--------------------------------------+----------------+-----------------+---------------+--------+--------------------------------------+----------------+
[6] Verify possible access or not. The example is on the Network Node that can access to Neutron private network namespace, and verify to access to the VIP of LB.
root@network:~#
ip netns

qrouter-c51bc54c-9c42-457b-ba3d-b42d715c9a33 (id: 1)
qdhcp-596c0921-5acb-42e1-8b44-ff549c30cded (id: 0)
# load-balanced by ROUND_ROBIN

root@network:~#
ip netns exec qrouter-c51bc54c-9c42-457b-ba3d-b42d715c9a33 curl 192.168.100.79

Web_Server_01
root@network:~#
ip netns exec qrouter-c51bc54c-9c42-457b-ba3d-b42d715c9a33 curl 192.168.100.79

Web_Server_02
root@network:~#
ip netns exec qrouter-c51bc54c-9c42-457b-ba3d-b42d715c9a33 curl 192.168.100.79

Web_Server_01
[7] To assosiate floating IP with VIP-Port of LB, it's possible to access from public network.
ubuntu@dlp ~(keystone)$
openstack floating ip list

+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+
| ID                                   | Floating IP Address | Fixed IP Address | Port | Floating Network                     | Project                          |
+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+
| 602c7a0e-705b-4933-ae26-a06fb24f77b0 | 10.0.0.202          | None             | None | 4ac44922-6ee9-4f99-9901-06cd69bcb64b | ff03eefa265b423aa3375acb46a8e4e0 |
+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+

ubuntu@dlp ~(keystone)$
neutron lbaas-loadbalancer-show lb01

+---------------------+------------------------------------------------+
| Field               | Value                                          |
+---------------------+------------------------------------------------+
| admin_state_up      | True                                           |
| description         |                                                |
| id                  | 73e22025-12cb-41aa-bfd7-2f9a3f74fd5d           |
| listeners           | {"id": "a68885c0-44dc-4e17-a725-ae1464871c86"} |
| name                | lb01                                           |
| operating_status    | ONLINE                                         |
| pools               | {"id": "94ab097d-29bd-4e34-b659-bd7b1aa3b92d"} |
| provider            | haproxy                                        |
| provisioning_status | ACTIVE                                         |
| tenant_id           | ff03eefa265b423aa3375acb46a8e4e0               |
| vip_address         | 192.168.100.79                                 |
| vip_port_id         | d5d89d1e-c47b-4e74-b5d8-9809f46050fb           |
| vip_subnet_id       | d09f2fd8-07d9-4365-9e5b-5aeb471a1b72           |
+---------------------+------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack floating ip set --port d5d89d1e-c47b-4e74-b5d8-9809f46050fb 10.0.0.202
ubuntu@dlp ~(keystone)$
curl 10.0.0.202

Web_Server_01
ubuntu@dlp ~(keystone)$
curl 10.0.0.202

Web_Server_02
ubuntu@dlp ~(keystone)$
curl 10.0.0.202

Web_Server_01
Matched Content