CentOS Stream 9
Sponsored Link

OpenStack Dalmatian : How to use Octavia2024/10/16

 

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.
# install from Dalmatian, EPEL, CRB

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-dalmatian,epel,crb -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)
[cent@dlp ~(keystone)]$
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 8fbc394a-e821-47d8-8efc-d5f7c7db0ff8 | public-subnet  | 7302c07e-c543-4a85-a955-d6cc8a4e4011 | 10.0.0.0/24      |
| dfb0949d-d775-4c17-9b07-b01ac7d71aac | private-subnet | aa200aa9-ddb2-4d89-aa37-ce3e3a939421 | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2024-10-16T00:11:42                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 73c85621-edfa-408a-8d6b-6249e684b7ed |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | 756e2b4937c44d3991028e294f92d89a     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.127                      |
| vip_network_id      | aa200aa9-ddb2-4d89-aa37-ce3e3a939421 |
| vip_port_id         | 348543ce-dae1-4067-a188-c3a86104a730 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | dfb0949d-d775-4c17-9b07-b01ac7d71aac |
| vip_vnic_type       | normal                               |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| 73c85621-edfa-408a-8d6b-6249e684b7ed | lb01 | 756e2b4937c44d3991028e294f92d89a | 192.168.100.127 | 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

[cent@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                  | 2024-10-16T00:15:35                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 988bd165-2f71-45d7-9c50-0a2250afc71f |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 73c85621-edfa-408a-8d6b-6249e684b7ed |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | 756e2b4937c44d3991028e294f92d89a     |
| 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

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

+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| admin_state_up       | True                                 |
| created_at           | 2024-10-16T00:15:56                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 443396ae-bf55-49c8-8e74-1048d5faade4 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 988bd165-2f71-45d7-9c50-0a2250afc71f |
| loadbalancers        | 73c85621-edfa-408a-8d6b-6249e684b7ed |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | 756e2b4937c44d3991028e294f92d89a     |
| 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

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+-------+--------+-------------------------+----------------+----------+
| ID                                   | Name  | Status | Networks                | Image          | Flavor   |
+--------------------------------------+-------+--------+-------------------------+----------------+----------+
| a9f1cb25-0832-4977-95ed-518698a2df1b | Web02 | ACTIVE | private=192.168.100.92  | CentOS-Stream9 | m1.small |
| bee5ba22-2491-4c43-b8c9-d2ca62d2ed18 | Web01 | ACTIVE | private=192.168.100.105 | CentOS-Stream9 | m1.small |
+--------------------------------------+-------+--------+-------------------------+----------------+----------+

# add web server instances to the pool member

[cent@dlp ~(keystone)]$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.92 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.92                       |
| admin_state_up      | True                                 |
| created_at          | 2024-10-16T00:22:09                  |
| id                  | 4b26b978-efae-473c-b9b5-a9e6aa6c4744 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 756e2b4937c44d3991028e294f92d89a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | dfb0949d-d775-4c17-9b07-b01ac7d71aac |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
| vnic_type           | normal                               |
+---------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.105 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.105                      |
| admin_state_up      | True                                 |
| created_at          | 2024-10-16T00:22:28                  |
| id                  | f22c79ae-463e-4d01-884a-0a2a7877e8fa |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 756e2b4937c44d3991028e294f92d89a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | dfb0949d-d775-4c17-9b07-b01ac7d71aac |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
| vnic_type           | normal                               |
+---------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack loadbalancer member list pool01

+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address         | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 4b26b978-efae-473c-b9b5-a9e6aa6c4744 |      | 756e2b4937c44d3991028e294f92d89a | ACTIVE              | 192.168.100.92  |            80 | NO_MONITOR       |      1 |
| f22c79ae-463e-4d01-884a-0a2a7877e8fa |      | 756e2b4937c44d3991028e294f92d89a | ACTIVE              | 192.168.100.105 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

# create a floating IP on public network

[cent@dlp ~(keystone)]$
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2024-10-16T00:23:09Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.254                           |
| floating_network_id | 7302c07e-c543-4a85-a955-d6cc8a4e4011 |
| id                  | b7ee72cf-18fc-4af0-a69f-aff487fa9554 |
| name                | 10.0.0.254                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | 756e2b4937c44d3991028e294f92d89a     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2024-10-16T00:23:09Z                 |
+---------------------+--------------------------------------+

# associate floating IP with VIP of loadbalancer instace

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

[cent@dlp ~(keystone)]$
openstack floating ip set --port $VIPPORT 10.0.0.254
# verify settings to access to the floating IP

[cent@dlp ~(keystone)]$
curl 10.0.0.254

Web Server on Instance01
[cent@dlp ~(keystone)]$
curl 10.0.0.254

Web Server on Instance02
[cent@dlp ~(keystone)]$
curl 10.0.0.254

Web Server on Instance01
[cent@dlp ~(keystone)]$
curl 10.0.0.254

Web Server on Instance02
Matched Content