OpenStack Wallaby : How to use Octavia2021/04/26 |
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 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ 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 Volume | | OVN Metadata Agent | | Cinder API | | iSCSI Target | | 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 | +--------------------------------------+----------------+--------------------------------------+------------------+ | c7799645-dd7a-4347-b341-58f995d2f83e | private-subnet | 0538d835-a80f-4a32-a460-4c2001bebc49 | 192.168.100.0/24 | | f9e1cbc7-0f73-4cae-960e-c3ca930d5ff6 | public-subnet | 2cc12720-71da-4e48-810d-ec5306278a8b | 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 | 2021-04-26T03:26:06 | | description | | | flavor_id | None | | id | 94357268-a4ec-404d-8ebe-37c3bf6a77a1 | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | 5740dfa09acd480aaf87b406af946eaf | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.84 | | vip_network_id | 0538d835-a80f-4a32-a460-4c2001bebc49 | | vip_port_id | d0ee7275-7e2d-4e45-9c56-bfecb5c09d60 | | vip_qos_policy_id | None | | vip_subnet_id | c7799645-dd7a-4347-b341-58f995d2f83e | | tags | | +---------------------+--------------------------------------+ # after a few minutes, stauts turns to [ACTIVE] if instance successfully created [root@dlp ~(keystone)]# openstack loadbalancer list +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | id | name | project_id | vip_address | provisioning_status | operating_status | provider | +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | 94357268-a4ec-404d-8ebe-37c3bf6a77a1 | lb01 | 5740dfa09acd480aaf87b406af946eaf | 192.168.100.84 | 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 | 2021-04-26T03:28:15 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | ffe8a7a1-c8a1-4650-b333-ea500668bd23 | | insert_headers | None | | l7policies | | | loadbalancers | 94357268-a4ec-404d-8ebe-37c3bf6a77a1 | | name | listener01 | | operating_status | OFFLINE | | project_id | 5740dfa09acd480aaf87b406af946eaf | | 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 | 2021-04-26T03:28:31 | | description | | | healthmonitor_id | | | id | 0986bc29-2ab6-484d-9c32-3b5145a391b8 | | lb_algorithm | ROUND_ROBIN | | listeners | ffe8a7a1-c8a1-4650-b333-ea500668bd23 | | loadbalancers | 94357268-a4ec-404d-8ebe-37c3bf6a77a1 | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | 5740dfa09acd480aaf87b406af946eaf | | 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 | +--------------------------------------+-------+--------+-------------------------+-----------------+----------+ | 7e3f2d91-febf-40da-972d-1ab3d778e9d4 | Web02 | ACTIVE | private=192.168.100.188 | CentOS-Stream-8 | m1.small | | 898cac93-6562-4fc7-bc10-70ddbaeca933 | Web01 | ACTIVE | private=192.168.100.148 | CentOS-Stream-8 | 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.148 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.148 | | admin_state_up | True | | created_at | 2021-04-26T03:31:29 | | id | b754178b-eadc-4113-b6c2-21f112cb3e5a | | name | | | operating_status | NO_MONITOR | | project_id | 5740dfa09acd480aaf87b406af946eaf | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | c7799645-dd7a-4347-b341-58f995d2f83e | | 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.188 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.188 | | admin_state_up | True | | created_at | 2021-04-26T03:31:45 | | id | 70fe0657-5562-4d8f-b51f-c6378b171c9b | | name | | | operating_status | NO_MONITOR | | project_id | 5740dfa09acd480aaf87b406af946eaf | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | c7799645-dd7a-4347-b341-58f995d2f83e | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | b754178b-eadc-4113-b6c2-21f112cb3e5a | | 5740dfa09acd480aaf87b406af946eaf | ACTIVE | 192.168.100.148 | 80 | NO_MONITOR | 1 | | 70fe0657-5562-4d8f-b51f-c6378b171c9b | | 5740dfa09acd480aaf87b406af946eaf | ACTIVE | 192.168.100.188 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # create a floating IP on public network [root@dlp ~(keystone)]# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2021-04-26T03:32:41Z | | description | | | dns_domain | None | | dns_name | None | | fixed_ip_address | None | | floating_ip_address | 10.0.0.216 | | floating_network_id | 2cc12720-71da-4e48-810d-ec5306278a8b | | id | 0019c198-e134-4548-9212-d6b4464e6949 | | name | 10.0.0.216 | | port_details | None | | port_id | None | | project_id | 5740dfa09acd480aaf87b406af946eaf | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2021-04-26T03:32:41Z | +---------------------+--------------------------------------+ # assosiate 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.216
# verify settings to access to the floating IP [root@dlp ~(keystone)]# curl 10.0.0.216 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.216 Web Server on Instance02 [root@dlp ~(keystone)]# curl 10.0.0.216 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.216 Web Server on Instance02 |
Sponsored Link |
|