OpenStack Yoga : How to use Octavia2022/06/10 |
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 httpd | | Neutron Server | | Nova Compute | | Keystone Glance | | OVN-Northd | | Open vSwitch | | Nova API Cinder API | | Cinder Volume | | OVN Metadata Agent | | | | Octavia Services | | OVN-Controller | +-----------------------+ +-----------------------+ +-----------------------+ |
[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 | +--------------------------------------+----------------+--------------------------------------+------------------+ | 50ab40e2-c1ff-4371-a829-bbc228ddd16f | public-subnet | 9669b364-5e91-4858-bff1-437a23be347b | 10.0.0.0/24 | | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | private-subnet | c4ede804-96e1-4b1b-bf1b-341f752065c0 | 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-06-10T07:39:26 | | description | | | flavor_id | None | | id | b017a057-9c62-43fc-a135-b5b77b97ed4e | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.247 | | vip_network_id | c4ede804-96e1-4b1b-bf1b-341f752065c0 | | vip_port_id | 0e0a9f34-0b4c-414b-ae34-3476fa53d8a9 | | vip_qos_policy_id | None | | vip_subnet_id | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | | tags | | +---------------------+--------------------------------------+ # 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 | +--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+ | b017a057-9c62-43fc-a135-b5b77b97ed4e | lb01 | 9c8b7457e8db4cbc995a767706804b70 | 192.168.100.247 | 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-06-10T07:42:05 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | 11b83404-baea-4cbb-9a1c-ccd27c6bd752 | | insert_headers | None | | l7policies | | | loadbalancers | b017a057-9c62-43fc-a135-b5b77b97ed4e | | name | listener01 | | operating_status | OFFLINE | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | 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-06-10T07:42:29 | | description | | | healthmonitor_id | | | id | 3a3867ed-7ed6-4e7e-b228-8cf7fae7c62a | | lb_algorithm | ROUND_ROBIN | | listeners | 11b83404-baea-4cbb-9a1c-ccd27c6bd752 | | loadbalancers | b017a057-9c62-43fc-a135-b5b77b97ed4e | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | 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 | +--------------------------------------+----------------------------------------------+---------+--------------------------------------------+----------------+------------+ | 40642ab8-36db-429f-a90b-9c9df443992f | Web02 | ACTIVE | private=192.168.100.243 | CentOS-Stream9 | m1.small | | 63106ba1-eacc-4a23-a924-ea59317d5d05 | Web01 | ACTIVE | private=192.168.100.23 | CentOS-Stream9 | m1.small | | 40e58db0-8141-47a2-bd43-c45f38b3312d | amphora-542c92ad-d898-4bd1-b365-607bf5be59ee | ACTIVE | private=192.168.100.145; public=10.0.0.200 | Amphora | m1.octavia | +--------------------------------------+----------------------------------------------+---------+--------------------------------------------+----------------+------------+ # add web server instances to the pool member [root@dlp ~(keystone)]# openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.243 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.243 | | admin_state_up | True | | created_at | 2022-06-10T07:50:47 | | id | 6699760d-5a8c-4b08-a356-15910be163ed | | name | | | operating_status | NO_MONITOR | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | | 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.23 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.23 | | admin_state_up | True | | created_at | 2022-06-10T07:51:02 | | id | 6dfa05f2-dce2-4091-b0c4-6ccd796da7d0 | | name | | | operating_status | NO_MONITOR | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | 80a576b7-55e6-4d3b-86d9-26bb0c4e7d57 | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | 6699760d-5a8c-4b08-a356-15910be163ed | | 9c8b7457e8db4cbc995a767706804b70 | ACTIVE | 192.168.100.243 | 80 | NO_MONITOR | 1 | | 6dfa05f2-dce2-4091-b0c4-6ccd796da7d0 | | 9c8b7457e8db4cbc995a767706804b70 | ACTIVE | 192.168.100.23 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # create a floating IP on public network [root@dlp ~(keystone)]# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2022-06-10T07:52:03Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.246 | | floating_network_id | 9669b364-5e91-4858-bff1-437a23be347b | | id | 717361a3-fdc2-42c0-bf99-cfe7734e6265 | | name | 10.0.0.246 | | port_details | None | | port_id | None | | project_id | 9c8b7457e8db4cbc995a767706804b70 | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2022-06-10T07:52:03Z | +---------------------+--------------------------------------+ # 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.246
# verify settings to access to the floating IP [root@dlp ~(keystone)]# curl 10.0.0.246 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.246 Web Server on Instance02 [root@dlp ~(keystone)]# curl 10.0.0.246 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.246 Web Server on Instance02 |
Sponsored Link |