OpenStack Victoria : Octavia 利用方法2020/11/27 |
OpenStack Load Balancing as a Service(Octavia)の利用方法です。
当例では以下のような環境を例に Octavia をインストールしています。
ネットワーク環境は、こちらのリンク先の通り Geneve によるネットワークを構成しています。 ------------+---------------------------+---------------------------+------------ | | | 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 | | Octavia Services | | OVN Metadata Agent | | | | | | OVN-Controller | +-----------------------+ +-----------------------+ +-----------------------+ |
[1] | ロードバランサーインスタンスを作成します。デフォルトでは [admin] 権限のユーザーのみがインスタンス作成可能です。作業場所はどこでも良いですが当例では Control ノード上で行います。 |
[root@dlp ~(keystone)]# openstack subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | db0a36a6-5be6-4609-951e-27b4d3f9f5b9 | private-subnet | 431d7888-dcde-40dc-9727-ecfa65a25366 | 192.168.100.0/24 | | e09e5481-afaf-484e-9c7a-b24a3545d092 | public-subnet | dae78c9d-c885-4949-a05d-8e456f9ba1b9 | 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 | 2020-11-26T05:51:48 | | description | | | flavor_id | None | | id | 9a4aeebc-68fb-4e4e-ae5f-94ad9cb1ca44 | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | f631c12338934447bb3172f3378d2b9a | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.120 | | vip_network_id | 431d7888-dcde-40dc-9727-ecfa65a25366 | | vip_port_id | 4dec49a6-f9fd-4ba6-a23b-f85707a70640 | | vip_qos_policy_id | None | | vip_subnet_id | db0a36a6-5be6-4609-951e-27b4d3f9f5b9 | +---------------------+--------------------------------------+ # しばらく時間がたつと [ACTIVE] ステータスになり作成が完了する [root@dlp ~(keystone)]# openstack loadbalancer list +--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+ | id | name | project_id | vip_address | provisioning_status | operating_status | provider | +--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+ | 9a4aeebc-68fb-4e4e-ae5f-94ad9cb1ca44 | lb01 | f631c12338934447bb3172f3378d2b9a | 192.168.100.120 | 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 | 2020-11-26T05:54:59 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | cb27a811-f50f-44cc-95a2-c34dee021928 | | insert_headers | None | | l7policies | | | loadbalancers | 9a4aeebc-68fb-4e4e-ae5f-94ad9cb1ca44 | | name | listener01 | | operating_status | OFFLINE | | project_id | f631c12338934447bb3172f3378d2b9a | | 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 | +-----------------------------+--------------------------------------+ # 作成したリスナーにプール作成 [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 | 2020-11-26T05:55:17 | | description | | | healthmonitor_id | | | id | 79c101d8-5347-4737-add7-5e33ec51c056 | | lb_algorithm | ROUND_ROBIN | | listeners | cb27a811-f50f-44cc-95a2-c34dee021928 | | loadbalancers | 9a4aeebc-68fb-4e4e-ae5f-94ad9cb1ca44 | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | f631c12338934447bb3172f3378d2b9a | | 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 | +----------------------+--------------------------------------+ # Web サーバーが稼働する二つのインスタンス [root@dlp ~(keystone)]# openstack server list +--------------------------------------+---------------+--------+-------------------------+---------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+---------------+--------+-------------------------+---------+----------+ | 1df58f38-bac2-46a7-ba6d-fb21fc43d120 | CentOS-8-Web2 | ACTIVE | private=192.168.100.207 | CentOS8 | m1.small | | 65e97bf7-0561-437c-9301-f679bd81dc07 | CentOS-8-Web1 | ACTIVE | private=192.168.100.154 | CentOS8 | m1.small | +--------------------------------------+---------------+--------+-------------------------+---------+----------+ # 作成したプールのメンバーに加える [root@dlp ~(keystone)]# openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.207 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.207 | | admin_state_up | True | | created_at | 2020-11-26T05:59:27 | | id | 636cd334-0a11-421a-9926-370b30116724 | | name | | | operating_status | NO_MONITOR | | project_id | f631c12338934447bb3172f3378d2b9a | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | db0a36a6-5be6-4609-951e-27b4d3f9f5b9 | | updated_at | None | | weight | 1 | | monitor_port | None | | monitor_address | None | | backup | False | +---------------------+--------------------------------------+[root@dlp ~(keystone)]# openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.154 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.154 | | admin_state_up | True | | created_at | 2020-11-26T05:59:44 | | id | 0bf65bc4-03a3-4fe7-9991-fb7c67e3da2c | | name | | | operating_status | NO_MONITOR | | project_id | f631c12338934447bb3172f3378d2b9a | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | db0a36a6-5be6-4609-951e-27b4d3f9f5b9 | | updated_at | None | | weight | 1 | | monitor_port | None | | monitor_address | None | | backup | False | +---------------------+--------------------------------------+[root@dlp ~(keystone)]# openstack loadbalancer member list pool01 +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | id | name | project_id | provisioning_status | address | protocol_port | operating_status | weight | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | 636cd334-0a11-421a-9926-370b30116724 | | f631c12338934447bb3172f3378d2b9a | ACTIVE | 192.168.100.207 | 80 | NO_MONITOR | 1 | | 0bf65bc4-03a3-4fe7-9991-fb7c67e3da2c | | f631c12338934447bb3172f3378d2b9a | ACTIVE | 192.168.100.154 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # 外側ネットワークにフローティング IP 作成 [root@dlp ~(keystone)]# openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2020-11-26T06:00:16Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.250 | | floating_network_id | dae78c9d-c885-4949-a05d-8e456f9ba1b9 | | id | b107cd4e-c3a6-40ad-88b9-60e5b9af4ba7 | | name | 10.0.0.250 | | port_details | None | | port_id | None | | project_id | f631c12338934447bb3172f3378d2b9a | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2020-11-26T06:00:16Z | +---------------------+--------------------------------------+ # ロードバランサーインスタンスの 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.250
# フローティング IP 宛てにアクセスして動作確認 [root@dlp ~(keystone)]# curl 10.0.0.250 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.250 Web Server on Instance02 [root@dlp ~(keystone)]# curl 10.0.0.250 Web Server on Instance01 [root@dlp ~(keystone)]# curl 10.0.0.250 Web Server on Instance02 |
Sponsored Link |
|