Ubuntu 20.04
Sponsored Link

OpenStack Yoga : How to use Octavia2022/04/12

 
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
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Storage Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |      Open vSwitch     |   |        Libvirt        |
|  Memcached  httpd     |   |     Neutron Server    |   |     Nova Compute      |
|  Keystone   Glance    |   |       OVN-Northd      |   |      Open vSwitch     |
|  Nova API             |   |     Cinder Volume     |   |   OVN Metadata Agent  |
|  Cinder API           |   |    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           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 5d1edead-636e-4622-942a-bfd2347908e3 | private-subnet | b19c6ee5-26f7-4a98-8a8c-58a2e7637610 | 192.168.100.0/24 |
| 99f81758-a8a8-4a25-8c20-a8c52f374815 | public-subnet  | 8fd7472d-9182-4a17-aa35-984fb7fb059d | 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-04-12T04:53:40                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 3925a640-bf21-47d5-a0a0-2bd69e58fc60 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | ddb7c08ba73a48eea040270d13a7b0cf     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.41                       |
| vip_network_id      | b19c6ee5-26f7-4a98-8a8c-58a2e7637610 |
| vip_port_id         | a01a6e53-777a-45d8-a81d-392c0b98c1c2 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | 5d1edead-636e-4622-942a-bfd2347908e3 |
| tags                |                                      |
+---------------------+--------------------------------------+

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

root@dlp ~(keystone)#
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address    | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| 3925a640-bf21-47d5-a0a0-2bd69e58fc60 | lb01 | ddb7c08ba73a48eea040270d13a7b0cf | 192.168.100.41 | 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-04-12T04:55:53                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 7ba8f04a-083c-47ed-8c85-88f48b91abdd |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 3925a640-bf21-47d5-a0a0-2bd69e58fc60 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | ddb7c08ba73a48eea040270d13a7b0cf     |
| 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-04-12T04:56:40                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 4dc424cc-2023-46f4-811b-7b651978697b |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 7ba8f04a-083c-47ed-8c85-88f48b91abdd |
| loadbalancers        | 3925a640-bf21-47d5-a0a0-2bd69e58fc60 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | ddb7c08ba73a48eea040270d13a7b0cf     |
| 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     |
+--------------------------------------+----------------------------------------------+---------+--------------------------------------------+------------+------------+
| a113c516-2dbb-43b8-9a5d-9aad029bb147 | Web02                                        | ACTIVE  | private=192.168.100.101                    | Ubuntu2004 | m1.small   |
| 22591df1-91b9-4efa-b3be-a32bb09bb7cc | Web01                                        | ACTIVE  | private=192.168.100.214                    | Ubuntu2004 | m1.small   |
| 6b22fd88-4438-4387-960b-e1d2f4f8c416 | amphora-8be98176-c389-4836-833d-19f676a998c0 | ACTIVE  | private=192.168.100.102; public=10.0.0.216 | Amphora    | m1.octavia |
| 90aff00b-7f8f-4d4c-8929-85c4dbe555df | Ubuntu-2004                                  | SHUTOFF | private=10.0.0.242, 192.168.100.134        | Ubuntu2004 | 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.214 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.214                      |
| admin_state_up      | True                                 |
| created_at          | 2022-04-12T04:59:33                  |
| id                  | 01ed1232-63b3-4eec-a9e4-45c0abd6586c |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | ddb7c08ba73a48eea040270d13a7b0cf     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 5d1edead-636e-4622-942a-bfd2347908e3 |
| 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.101 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.101                      |
| admin_state_up      | True                                 |
| created_at          | 2022-04-12T04:59:49                  |
| id                  | 3512e6b2-7b39-4bab-8287-95fcccf56e9e |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | ddb7c08ba73a48eea040270d13a7b0cf     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 5d1edead-636e-4622-942a-bfd2347908e3 |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 01ed1232-63b3-4eec-a9e4-45c0abd6586c |      | ddb7c08ba73a48eea040270d13a7b0cf | ACTIVE              | 192.168.100.214 |            80 | NO_MONITOR       |      1 |
| 3512e6b2-7b39-4bab-8287-95fcccf56e9e |      | ddb7c08ba73a48eea040270d13a7b0cf | ACTIVE              | 192.168.100.101 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

# create a floating IP on public network

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2022-04-12T05:00:19Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.223                           |
| floating_network_id | 8fd7472d-9182-4a17-aa35-984fb7fb059d |
| id                  | 51b6ffd6-ad4a-4bbd-9896-48985e6ae0c3 |
| name                | 10.0.0.223                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | ddb7c08ba73a48eea040270d13a7b0cf     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2022-04-12T05:00:19Z                 |
+---------------------+--------------------------------------+

# assosiate 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.223
# verify settings to access to the floating IP

root@dlp ~(keystone)#
curl 10.0.0.223

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

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

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

Web Server on Instance02
Matched Content