Ubuntu 22.04
Sponsored Link

OpenStack Bobcat : How to use Octavia2023/10/09

 
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  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |    Octavia Services   |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] Install Octavia client tool.
root@dlp ~(keystone)#
apt -y install python3-octaviaclient
[2] Login as any Openstack user and create Loadbalancer instance.
It's OK to work on any node. (example below is on Control Node)
ubuntu@dlp ~(keystone)$
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| e14c5e7d-41d0-4378-af0f-0993c4389593 | private-subnet | 529ae54a-4bba-40a3-905d-2ca57557236a | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2023-10-09T02:12:17                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | ec3dfec8-1008-4a5c-a171-4ed2615b9b04 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | f30cd546632e484cb24414d83207694b     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.12                       |
| vip_network_id      | 529ae54a-4bba-40a3-905d-2ca57557236a |
| vip_port_id         | 2ed63575-343c-4602-a920-9c0c45c56003 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | e14c5e7d-41d0-4378-af0f-0993c4389593 |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

ubuntu@dlp ~(keystone)$
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address    | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| ec3dfec8-1008-4a5c-a171-4ed2615b9b04 | lb01 | f30cd546632e484cb24414d83207694b | 192.168.100.12 | ACTIVE              | OFFLINE          | amphora  |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
[3] 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

ubuntu@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                  | 2023-10-09T02:13:21                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 28348127-3cf8-43b6-9f26-55e93bb290d7 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | ec3dfec8-1008-4a5c-a171-4ed2615b9b04 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | f30cd546632e484cb24414d83207694b     |
| 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                        |                                      |
| hsts_max_age                | None                                 |
| hsts_include_subdomains     | False                                |
| hsts_preload                | False                                |
+-----------------------------+--------------------------------------+

# add a pool to the listener

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

+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| admin_state_up       | True                                 |
| created_at           | 2023-10-09T02:13:59                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 93d3459b-0e7e-406a-8a08-27c739620826 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 28348127-3cf8-43b6-9f26-55e93bb290d7 |
| loadbalancers        | ec3dfec8-1008-4a5c-a171-4ed2615b9b04 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | f30cd546632e484cb24414d83207694b     |
| 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

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+---------+------------------------------------+------------+-----------+
| ID                                   | Name        | Status  | Networks                           | Image      | Flavor    |
+--------------------------------------+-------------+---------+------------------------------------+------------+-----------+
| 0f3b7e03-333b-4d6c-b5ca-b8fa5c5418a5 | Web02       | ACTIVE  | private=192.168.100.43             | Ubuntu2204 | m1.medium |
| 1b60f8cb-a463-4eaf-9c07-d9b8eb078c25 | Web01       | ACTIVE  | private=192.168.100.30             | Ubuntu2204 | m1.medium |
| 530698ed-413e-4bda-b02e-8f6f60380bd1 | Ubuntu-2204 | SHUTOFF | private=10.0.0.222, 192.168.100.79 | Ubuntu2204 | m1.medium |
+--------------------------------------+-------------+---------+------------------------------------+------------+-----------+

# add web server instances to the pool member

ubuntu@dlp ~(keystone)$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.43 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.43                       |
| admin_state_up      | True                                 |
| created_at          | 2023-10-09T02:27:47                  |
| id                  | 3708260b-14d7-4d6c-959e-5b316f1799fa |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f30cd546632e484cb24414d83207694b     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | e14c5e7d-41d0-4378-af0f-0993c4389593 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.30 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.30                       |
| admin_state_up      | True                                 |
| created_at          | 2023-10-09T02:28:14                  |
| id                  | 97c2915a-1250-476b-a921-9b121711ee13 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f30cd546632e484cb24414d83207694b     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | e14c5e7d-41d0-4378-af0f-0993c4389593 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack loadbalancer member list pool01

+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address        | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+
| 3708260b-14d7-4d6c-959e-5b316f1799fa |      | f30cd546632e484cb24414d83207694b | ACTIVE              | 192.168.100.43 |            80 | NO_MONITOR       |      1 |
| 97c2915a-1250-476b-a921-9b121711ee13 |      | f30cd546632e484cb24414d83207694b | ACTIVE              | 192.168.100.30 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+

# create a floating IP on public network

ubuntu@dlp ~(keystone)$
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2023-10-09T02:29:23Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.236                           |
| floating_network_id | 1d42f5e1-1ff2-4f70-8c48-8c7f6eae0672 |
| id                  | 745f488c-dc16-402a-8815-3ebb1ff8cf2a |
| name                | 10.0.0.236                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | f30cd546632e484cb24414d83207694b     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2023-10-09T02:29:23Z                 |
+---------------------+--------------------------------------+

# associate floating IP with VIP of loadbalancer instace

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

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

ubuntu@dlp ~(keystone)$
curl 10.0.0.236

Web Server on Instance01
ubuntu@dlp ~(keystone)$
curl 10.0.0.236

Web Server on Instance02
ubuntu@dlp ~(keystone)$
curl 10.0.0.236

Web Server on Instance01
ubuntu@dlp ~(keystone)$
curl 10.0.0.236

Web Server on Instance02
Matched Content