OpenStack Wallaby : Octavia 利用方法2021/04/21 |
OpenStack Load Balancing as a Service(Octavia)の利用方法です。
当例では以下のような環境を例に Octavia をインストールしています。
------------+---------------------------+---------------------------+------------ | | | eth0|10.0.0.30 eth0|10.0.0.50 eth0|10.0.0.51 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ Control Node ] | | [ Storage 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 | | Octavia Services | | OVN-Controller | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | ロードバランサーインスタンスを作成します。デフォルトでは [admin] 権限のユーザーのみがインスタンス作成可能です。 作業場所はどこでも良いですが当例では Control ノード上で行います。 |
root@dlp ~(keystone)#
root@dlp ~(keystone)# apt -y install python3-octaviaclient openstack subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | c11c200c-d463-4330-beaf-80ab87ead256 | private-subnet | ca2c4289-f0e7-42dc-95d4-ea9507567541 | 192.168.100.0/24 | | e8c73b2b-a6c7-4d97-8782-df4d841f84eb | public-subnet | ffa87ed8-7da9-488c-a7c8-09912ca2443a | 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-21T00:01:46 | | description | | | flavor_id | None | | id | 8b48ab85-d5c6-4503-966b-024614fdbec9 | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.70 | | vip_network_id | ca2c4289-f0e7-42dc-95d4-ea9507567541 | | vip_port_id | 40ff7cff-b641-4499-b1b2-a288004457f5 | | vip_qos_policy_id | None | | vip_subnet_id | c11c200c-d463-4330-beaf-80ab87ead256 | | tags | | +---------------------+--------------------------------------+ # しばらく時間がたつと [ACTIVE] ステータスになり作成が完了する root@dlp ~(keystone)# openstack loadbalancer list +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | id | name | project_id | vip_address | provisioning_status | operating_status | provider | +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | 8b48ab85-d5c6-4503-966b-024614fdbec9 | lb01 | da2214d30eaa4b7aaae25c8cbba0483e | 192.168.100.70 | ACTIVE | OFFLINE | amphora | +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ |
[2] | ロードバランサーインスタンスにリスナーやメンバーを追加して、バックエンドの Web サーバーが稼働する二つのインスタンスをラウンドロビンで負荷分散するよう設定します。 |
# 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-21T00:07:42 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | 787c1a3a-2d14-4dda-9876-12cf2f0aa701 | | insert_headers | None | | l7policies | | | loadbalancers | 8b48ab85-d5c6-4503-966b-024614fdbec9 | | name | listener01 | | operating_status | OFFLINE | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | 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 | | +-----------------------------+--------------------------------------+ # 作成したリスナーにプール作成 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-21T00:07:59 | | description | | | healthmonitor_id | | | id | 193b4060-a3ac-49e5-b1d8-2dc6727b26a1 | | lb_algorithm | ROUND_ROBIN | | listeners | 787c1a3a-2d14-4dda-9876-12cf2f0aa701 | | loadbalancers | 8b48ab85-d5c6-4503-966b-024614fdbec9 | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | 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 サーバーが稼働する二つのインスタンス root@dlp ~(keystone)# openstack server list +--------------------------------------+-------+--------+-------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------+--------+-------------------------+------------+----------+ | 3a92ab6e-285c-4b6e-b8c2-57846a42fe07 | Web02 | ACTIVE | private=192.168.100.43 | Ubuntu2004 | m1.small | | d92fb2a6-cf14-4b9b-9275-132cb6b77d4d | Web01 | ACTIVE | private=192.168.100.132 | Ubuntu2004 | m1.small | +--------------------------------------+-------+--------+-------------------------+------------+----------+ # 作成したプールのメンバーに加える root@dlp ~(keystone)# openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.43 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.43 | | admin_state_up | True | | created_at | 2021-04-21T00:11:29 | | id | ad553424-505c-46b9-aa7c-acc5a9ad6d4a | | name | | | operating_status | NO_MONITOR | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | c11c200c-d463-4330-beaf-80ab87ead256 | | 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.132 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.132 | | admin_state_up | True | | created_at | 2021-04-21T00:11:46 | | id | 41296ce4-5320-4207-a11b-159ab6c437ea | | name | | | operating_status | NO_MONITOR | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | c11c200c-d463-4330-beaf-80ab87ead256 | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | ad553424-505c-46b9-aa7c-acc5a9ad6d4a | | da2214d30eaa4b7aaae25c8cbba0483e | ACTIVE | 192.168.100.43 | 80 | NO_MONITOR | 1 | | 41296ce4-5320-4207-a11b-159ab6c437ea | | da2214d30eaa4b7aaae25c8cbba0483e | ACTIVE | 192.168.100.132 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # 外側ネットワークにフローティング IP 作成 root@dlp ~(keystone)# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2021-04-21T00:12:21Z | | description | | | dns_domain | None | | dns_name | None | | fixed_ip_address | None | | floating_ip_address | 10.0.0.224 | | floating_network_id | ffa87ed8-7da9-488c-a7c8-09912ca2443a | | id | d3be5ad8-42e6-48a4-b89a-5af3c017aa45 | | name | 10.0.0.224 | | port_details | None | | port_id | None | | project_id | da2214d30eaa4b7aaae25c8cbba0483e | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2021-04-21T00:12:21Z | +---------------------+--------------------------------------+ # ロードバランサーインスタンスの VIP とフローティング IP を関連付ける 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.224
# フローティング IP 宛てにアクセスして動作確認 root@dlp ~(keystone)# curl 10.0.0.224 Web Server on Instance01 root@dlp ~(keystone)# curl 10.0.0.224 Web Server on Instance02 root@dlp ~(keystone)# curl 10.0.0.224 Web Server on Instance01 root@dlp ~(keystone)# curl 10.0.0.224 Web Server on Instance02 |
Sponsored Link |