OpenStack Zed : How to use Octavia2022/11/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 a 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)]# openstack subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | 80213093-ac95-469a-b4d9-8c6adc93cfe1 | public-subnet | 004ca400-3d79-4c1b-b8fb-bba1e273000e | 10.0.0.0/24 | | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | private-subnet | c9c79a1d-136e-4036-8fe0-eaac79f05f5d | 192.168.100.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-11-11T05:14:26 | | description | | | flavor_id | None | | id | 064cb7f3-06f6-47d4-992f-01780a3c3fde | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.220 | | vip_network_id | c9c79a1d-136e-4036-8fe0-eaac79f05f5d | | vip_port_id | 1f7a65b5-cbb5-43a7-a512-dd97d7f3353e | | vip_qos_policy_id | None | | vip_subnet_id | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | | 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 | +--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+ | 064cb7f3-06f6-47d4-992f-01780a3c3fde | lb01 | 939974d6fc8e400eb01f7dd749935ea3 | 192.168.100.220 | 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-11-11T05:16:10 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | e09c4016-0431-40b8-bc01-2ede25d7639d | | insert_headers | None | | l7policies | | | loadbalancers | 064cb7f3-06f6-47d4-992f-01780a3c3fde | | name | listener01 | | operating_status | OFFLINE | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | 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-11-11T05:16:33 | | description | | | healthmonitor_id | | | id | 1ad35911-0a45-4328-9491-279fda67b960 | | lb_algorithm | ROUND_ROBIN | | listeners | e09c4016-0431-40b8-bc01-2ede25d7639d | | loadbalancers | 064cb7f3-06f6-47d4-992f-01780a3c3fde | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | 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 +--------------------------------------+----------------------------------------------+---------+-------------------------------------------+----------------+------------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------------------------------------------+---------+-------------------------------------------+----------------+------------+ | fbd8c67a-90da-4012-8bf2-22f593e0bf74 | Web02 | ACTIVE | private=192.168.100.20 | CentOS-Stream9 | m1.small | | de9ae73a-5897-47d1-8233-d5da83135c4b | Web01 | ACTIVE | private=192.168.100.229 | CentOS-Stream9 | m1.small | | f5edeeda-b04e-457a-8552-dfac44e86899 | amphora-ad8fa77c-dab4-4bd0-a7e7-81d9f08ffb03 | ACTIVE | private=192.168.100.90; public=10.0.0.229 | Amphora | m1.octavia | | 158685ed-8159-4aad-a294-3227b427f7e1 | CentOS-St9 | SHUTOFF | private=10.0.0.218, 192.168.100.75 | CentOS-Stream9 | 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.20 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.20 | | admin_state_up | True | | created_at | 2022-11-11T05:24:59 | | id | a7004bfc-70dd-4ef9-a96a-566542c48b6e | | name | | | operating_status | NO_MONITOR | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | | 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.229 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.229 | | admin_state_up | True | | created_at | 2022-11-11T05:25:18 | | id | 99136974-072c-4e98-bb4c-144af4b3c578 | | name | | | operating_status | NO_MONITOR | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | a7004bfc-70dd-4ef9-a96a-566542c48b6e | | 939974d6fc8e400eb01f7dd749935ea3 | ACTIVE | 192.168.100.20 | 80 | NO_MONITOR | 1 | | 99136974-072c-4e98-bb4c-144af4b3c578 | | 939974d6fc8e400eb01f7dd749935ea3 | ACTIVE | 192.168.100.229 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # create a floating IP on public network [root@dlp ~(keystone)]# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2022-11-11T05:25:59Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.201 | | floating_network_id | 004ca400-3d79-4c1b-b8fb-bba1e273000e | | id | 5a95b6d8-aa69-4e43-be97-5c631c8d869e | | name | 10.0.0.201 | | port_details | None | | port_id | None | | project_id | 939974d6fc8e400eb01f7dd749935ea3 | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2022-11-11T05:25:59Z | +---------------------+--------------------------------------+ # 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.201
# verify settings to access to the floating IP [root@dlp ~(keystone)]# curl 10.0.0.201 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.201 Web Server on Instance02 [root@dlp ~(keystone)]# curl 10.0.0.201 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.201 Web Server on Instance02 |
Sponsored Link |