OpenStack Zed : How to use Octavia2022/10/11 |
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] | 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)#
root@dlp ~(keystone)# apt -y install python3-octaviaclient openstack subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | a454cf3e-fef5-46f6-8468-4a26cbd14983 | private-subnet | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | 192.168.100.0/24 | | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | public-subnet | 394ec727-7e9a-473e-8068-45aa841a9ac2 | 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-10-10T08:43:00 | | description | | | flavor_id | None | | id | 2dcc0dda-0857-4a2c-9fb9-f2538c72e087 | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | 231a529f51394426b07c56f2c5ec580e | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.9 | | vip_network_id | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | | vip_port_id | 7026a32d-4565-4980-942b-30b9574494a9 | | vip_qos_policy_id | None | | vip_subnet_id | a454cf3e-fef5-46f6-8468-4a26cbd14983 | | tags | | | additional_vips | [] | +---------------------+--------------------------------------+ # 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 | +--------------------------------------+------+----------------------------------+---------------+---------------------+------------------+----------+ | 2dcc0dda-0857-4a2c-9fb9-f2538c72e087 | lb01 | 231a529f51394426b07c56f2c5ec580e | 192.168.100.9 | 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-10-10T09:20:08 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | 109ca408-2583-4e97-8286-ddebd1671a66 | | insert_headers | None | | l7policies | | | loadbalancers | 2dcc0dda-0857-4a2c-9fb9-f2538c72e087 | | name | listener01 | | operating_status | OFFLINE | | project_id | 231a529f51394426b07c56f2c5ec580e | | 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-10-10T09:20:39 | | description | | | healthmonitor_id | | | id | 816229cc-7f6e-4c58-a640-d0da536f1332 | | lb_algorithm | ROUND_ROBIN | | listeners | 109ca408-2583-4e97-8286-ddebd1671a66 | | loadbalancers | 2dcc0dda-0857-4a2c-9fb9-f2538c72e087 | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | 231a529f51394426b07c56f2c5ec580e | | 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 | +--------------------------------------+----------------------------------------------+---------+--------------------------------------------+------------+------------+ | 966ef716-a7ea-4763-86b3-82f156f1cb0e | Web02 | ACTIVE | private=192.168.100.195 | Ubuntu2204 | m1.small | | 4ab3eef5-00c5-44d9-bf95-008146a7aae5 | Web01 | ACTIVE | private=192.168.100.97 | Ubuntu2204 | m1.small | | 1ce35b3f-5c7e-4920-8186-33462e02bff9 | amphora-72c497cb-bb1d-4910-9b8b-d186336b86c9 | ACTIVE | private=192.168.100.169; public=10.0.0.214 | Amphora | m1.octavia | | a456ee32-b105-4c5e-8eae-ddccb48f913e | Ubuntu-2204 | SHUTOFF | private=10.0.0.228, 192.168.100.187 | 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.195 | | admin_state_up | True | | created_at | 2022-10-10T09:33:08 | | id | 35c1e58c-5981-41d3-837b-f361b1894ffe | | name | | | operating_status | NO_MONITOR | | project_id | 231a529f51394426b07c56f2c5ec580e | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | a454cf3e-fef5-46f6-8468-4a26cbd14983 | | 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.97 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.97 | | admin_state_up | True | | created_at | 2022-10-10T09:33:31 | | id | 0c804ffd-8aeb-4bcc-a213-850e5b0e8e67 | | name | | | operating_status | NO_MONITOR | | project_id | 231a529f51394426b07c56f2c5ec580e | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | a454cf3e-fef5-46f6-8468-4a26cbd14983 | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | 35c1e58c-5981-41d3-837b-f361b1894ffe | | 231a529f51394426b07c56f2c5ec580e | ACTIVE | 192.168.100.195 | 80 | NO_MONITOR | 1 | | 0c804ffd-8aeb-4bcc-a213-850e5b0e8e67 | | 231a529f51394426b07c56f2c5ec580e | ACTIVE | 192.168.100.97 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # create a floating IP on public network root@dlp ~(keystone)# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2022-10-10T09:34:48Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.203 | | floating_network_id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | id | 5ad9e4a9-2fbc-4e50-b7ed-31c92b3b34bc | | name | 10.0.0.203 | | port_details | None | | port_id | None | | project_id | 231a529f51394426b07c56f2c5ec580e | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2022-10-10T09:34:48Z | +---------------------+--------------------------------------+ # 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.203
# verify settings to access to the floating IP root@dlp ~(keystone)# curl 10.0.0.203 Web Server on Instance01 root@dlp ~(keystone)# curl 10.0.0.203 Web Server on Instance02 root@dlp ~(keystone)# curl 10.0.0.203 Web Server on Instance01 root@dlp ~(keystone)# curl 10.0.0.203 Web Server on Instance02 |
Sponsored Link |
|