Ubuntu 22.04
Sponsored Link

OpenStack Yoga : How to use Octavia2022/05/05

 
Install and Configure OpenStack Load Balancing as a Service (Octavia).
This example is based on the environment like follows.
------------+-----------------------------+-----------------------------+------------
            |                             |                             |
        eth0|10.0.0.30                eth0|10.0.0.50                eth0|10.0.0.51
+-----------+-----------+     +-----------+-----------+     +-----------+-----------+
|   [ dlp.srv.world ]   |     | [ network.srv.world ] |     |  [ node01.srv.world ] |
|     (Control Node)    |     |     (Network Node)    |     |     (Compute Node)    |
|                       |     |                       |     |                       |
|  MariaDB    RabbitMQ  |     |      Open vSwitch     |     |        Libvirt        |
|  Memcached  httpd     |     |     Neutron Server    |     |      Nova Compute     |
|  Keystone   Glance    |     |      OVN-Northd       |     |      Open vSwitch     |
|  Nova API  Cinder API |     |     Cinder Volume     |     |   OVN Metadata Agent  |
|                       |     |    Octavia Services   |     |     OVN-Controller    |
+-----------------------+     +-----------------------+     +-----------------------+

[1] Create Loadbalancer instance. By default, [admin] users can create instances, so work as an admin user.
It's OK to work on any node. (example below is on Control Node)
root@dlp ~(keystone)#
apt -y install python3-octaviaclient
root@dlp ~(keystone)#
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| a602f687-a0d5-4d8d-ba1f-51e7c87a606b | private-subnet | 2d24c223-3059-4143-baea-c8dea27232b5 | 192.168.100.0/24 |
| f7fb2250-794e-4b55-af48-29816ed2a9ea | public-subnet  | ad1337fe-7b67-4e87-b4c4-9480bd60df8e | 10.0.0.0/24      |
+--------------------------------------+----------------+--------------------------------------+------------------+

root@dlp ~(keystone)#
openstack loadbalancer create --name lb01 --vip-subnet-id private-subnet

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2022-05-05T09:20:02                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 7b320a4f-95fd-49d5-8577-e00f7c20059e |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | de339c4cb5984140ab0b243364e3a0f7     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.106                      |
| vip_network_id      | 2d24c223-3059-4143-baea-c8dea27232b5 |
| vip_port_id         | ef79094a-e1df-4407-9818-47c1b8376181 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | a602f687-a0d5-4d8d-ba1f-51e7c87a606b |
| tags                |                                      |
+---------------------+--------------------------------------+

# after a few minutes, status turns to [ACTIVE] if instance successfully created

root@dlp ~(keystone)#
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| 7b320a4f-95fd-49d5-8577-e00f7c20059e | lb01 | de339c4cb5984140ab0b243364e3a0f7 | 192.168.100.106 | ACTIVE              | OFFLINE          | amphora  |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
[2] Add a listener and pool to the instance and Configure loadbalancing to use 2 backend Web Server instances.
# create a listener that listens TCP 80

root@dlp ~(keystone)#
openstack loadbalancer listener create --name listener01 --protocol TCP --protocol-port 80 lb01

+-----------------------------+--------------------------------------+
| Field                       | Value                                |
+-----------------------------+--------------------------------------+
| admin_state_up              | True                                 |
| connection_limit            | -1                                   |
| created_at                  | 2022-05-05T09:26:08                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | a4288021-ca95-4185-bf27-f3cde7b38d67 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 7b320a4f-95fd-49d5-8577-e00f7c20059e |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | de339c4cb5984140ab0b243364e3a0f7     |
| protocol                    | TCP                                  |
| protocol_port               | 80                                   |
| provisioning_status         | PENDING_CREATE                       |
| sni_container_refs          | []                                   |
| timeout_client_data         | 50000                                |
| timeout_member_connect      | 5000                                 |
| timeout_member_data         | 50000                                |
| timeout_tcp_inspect         | 0                                    |
| updated_at                  | None                                 |
| client_ca_tls_container_ref | None                                 |
| client_authentication       | NONE                                 |
| client_crl_container_ref    | None                                 |
| allowed_cidrs               | None                                 |
| tls_ciphers                 | None                                 |
| tls_versions                | None                                 |
| alpn_protocols              | None                                 |
| tags                        |                                      |
+-----------------------------+--------------------------------------+

# add a pool to the listener

root@dlp ~(keystone)#
openstack loadbalancer pool create --name pool01 --lb-algorithm ROUND_ROBIN --listener listener01 --protocol TCP

+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| admin_state_up       | True                                 |
| created_at           | 2022-05-05T09:26:27                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | f413534e-1a3e-45c7-aa25-887f562f8a85 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | a4288021-ca95-4185-bf27-f3cde7b38d67 |
| loadbalancers        | 7b320a4f-95fd-49d5-8577-e00f7c20059e |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | de339c4cb5984140ab0b243364e3a0f7     |
| protocol             | TCP                                  |
| provisioning_status  | PENDING_CREATE                       |
| session_persistence  | None                                 |
| updated_at           | None                                 |
| tls_container_ref    | None                                 |
| ca_tls_container_ref | None                                 |
| crl_container_ref    | None                                 |
| tls_enabled          | False                                |
| tls_ciphers          | None                                 |
| tls_versions         | None                                 |
| tags                 |                                      |
| alpn_protocols       | None                                 |
+----------------------+--------------------------------------+

# web server instances

root@dlp ~(keystone)#
openstack server list --all

+--------------------------------------+----------------------------------------------+---------+--------------------------------------------+------------+------------+
| ID                                   | Name                                         | Status  | Networks                                   | Image      | Flavor     |
+--------------------------------------+----------------------------------------------+---------+--------------------------------------------+------------+------------+
| 2cada7b8-a1a8-4772-a8de-dbe78c956d6f | Web02                                        | ACTIVE  | private=192.168.100.21                     | Ubuntu2204 | m1.small   |
| 0bc75645-1812-4ed5-a67e-d635cfbad8f6 | Web01                                        | ACTIVE  | private=192.168.100.175                    | Ubuntu2204 | m1.small   |
| c4af23dd-3c3b-4363-9183-74aaeba65943 | amphora-64fa99da-2db1-4965-b3cf-4bd114be3c11 | ACTIVE  | private=192.168.100.181; public=10.0.0.223 | Amphora    | m1.octavia |
| 6781b9c7-19c6-4419-a910-d0ae43c7526c | Ubuntu-2204                                  | SHUTOFF | private=10.0.0.203, 192.168.100.164        | Ubuntu2204 | m1.small   |
+--------------------------------------+----------------------------------------------+---------+--------------------------------------------+------------+------------+

# add web server instances to the pool member

root@dlp ~(keystone)#
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.21 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.21                       |
| admin_state_up      | True                                 |
| created_at          | 2022-05-05T10:14:54                  |
| id                  | 46aa2d4d-143f-4c3c-ad18-d4844d2a0dfb |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | de339c4cb5984140ab0b243364e3a0f7     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | a602f687-a0d5-4d8d-ba1f-51e7c87a606b |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

root@dlp ~(keystone)#
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.175 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.175                      |
| admin_state_up      | True                                 |
| created_at          | 2022-05-05T10:15:10                  |
| id                  | 0f56e26d-fe70-4ea2-ae0a-73e86ee52ab9 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | de339c4cb5984140ab0b243364e3a0f7     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | a602f687-a0d5-4d8d-ba1f-51e7c87a606b |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

root@dlp ~(keystone)#
openstack loadbalancer member list pool01

+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address         | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 46aa2d4d-143f-4c3c-ad18-d4844d2a0dfb |      | de339c4cb5984140ab0b243364e3a0f7 | ACTIVE              | 192.168.100.21  |            80 | NO_MONITOR       |      1 |
| 0f56e26d-fe70-4ea2-ae0a-73e86ee52ab9 |      | de339c4cb5984140ab0b243364e3a0f7 | ACTIVE              | 192.168.100.175 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

# create a floating IP on public network

root@dlp ~(keystone)#
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2022-05-05T10:15:44Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.213                           |
| floating_network_id | ad1337fe-7b67-4e87-b4c4-9480bd60df8e |
| id                  | 77d95d3c-0d3e-493d-a670-d75368f1eec5 |
| name                | 10.0.0.213                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | de339c4cb5984140ab0b243364e3a0f7     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2022-05-05T10:15:44Z                 |
+---------------------+--------------------------------------+

# associate floating IP with VIP of loadbalancer instace

root@dlp ~(keystone)#
VIPPORT=$(openstack loadbalancer show lb01 | grep vip_port_id | awk {'print $4'})

root@dlp ~(keystone)#
openstack floating ip set --port $VIPPORT 10.0.0.213
# verify settings to access to the floating IP

root@dlp ~(keystone)#
curl 10.0.0.213

Web Server on Instance01
root@dlp ~(keystone)#
curl 10.0.0.213

Web Server on Instance02
root@dlp ~(keystone)#
curl 10.0.0.213

Web Server on Instance01
root@dlp ~(keystone)#
curl 10.0.0.213

Web Server on Instance02
Matched Content