Ubuntu 20.04
Sponsored Link

OpenStack Xena : Octavia 利用方法2021/10/08

 
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)#
apt -y install python3-octaviaclient
root@dlp ~(keystone)#
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 694a93ec-762f-4c2e-b8f3-4f5aa72b631e | public-subnet  | 35816d4c-fa30-4901-8aa5-3749970fa706 | 10.0.0.0/24      |
| 77ab8a8b-9cca-4f4a-90c6-a61f8a58f08d | private-subnet | a5d44a8a-4980-4c19-a53a-26af6aabd732 | 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          | 2021-10-08T05:03:26                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 986331e6-be7e-4dd6-96c7-bb1ecde17b7a |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | f4431102f2d9415590e3ac11c616858a     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.177                      |
| vip_network_id      | a5d44a8a-4980-4c19-a53a-26af6aabd732 |
| vip_port_id         | 9948f5ae-c98f-4e8c-a1b0-38b8516ef7d7 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | 77ab8a8b-9cca-4f4a-90c6-a61f8a58f08d |
| tags                |                                      |
+---------------------+--------------------------------------+

# しばらく時間がたつと [ACTIVE] ステータスになり作成が完了する

root@dlp ~(keystone)#
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| 986331e6-be7e-4dd6-96c7-bb1ecde17b7a | lb01 | f4431102f2d9415590e3ac11c616858a | 192.168.100.177 | 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-10-08T05:08:19                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | cc123fd0-f28b-4077-a71f-4125be43126f |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 986331e6-be7e-4dd6-96c7-bb1ecde17b7a |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | f4431102f2d9415590e3ac11c616858a     |
| 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-10-08T05:08:36                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 01b0ce47-1f4a-4673-8669-3891fc9cecb7 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | cc123fd0-f28b-4077-a71f-4125be43126f |
| loadbalancers        | 986331e6-be7e-4dd6-96c7-bb1ecde17b7a |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | f4431102f2d9415590e3ac11c616858a     |
| 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 サーバーが稼働する 2つのインスタンス

root@dlp ~(keystone)#
openstack server list --all

+--------------------------------------+----------------------------------------------+---------+-------------------------------------------+------------+------------+
| ID                                   | Name                                         | Status  | Networks                                  | Image      | Flavor     |
+--------------------------------------+----------------------------------------------+---------+-------------------------------------------+------------+------------+
| 7cfa7b6b-ab77-46b0-a43a-5c7a1fd70c8b | Web02                                        | ACTIVE  | private=192.168.100.193                   | Ubuntu2004 | m1.small   |
| 5d25cb2b-7537-4a7b-ab10-5cca4c93828b | Web01                                        | ACTIVE  | private=192.168.100.53                    | Ubuntu2004 | m1.small   |
| d6b7dc51-51c4-4b50-998e-022304f0de3b | amphora-c71c1dea-eeb6-4778-9a12-8ef416887416 | ACTIVE  | private=192.168.100.29; public=10.0.0.222 | Amphora    | m1.octavia |
| 4699d575-1d94-4024-8323-9dfa3599c8d2 | Ubuntu-2004                                  | SHUTOFF | private=10.0.0.249, 192.168.100.237       | Ubuntu2004 | m1.small   |
+--------------------------------------+----------------------------------------------+---------+-------------------------------------------+------------+------------+

# 作成したプールのメンバーに加える

root@dlp ~(keystone)#
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.53 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.53                       |
| admin_state_up      | True                                 |
| created_at          | 2021-10-08T05:44:34                  |
| id                  | ff33cd0e-5f10-4442-9b92-240a2d18c6a5 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f4431102f2d9415590e3ac11c616858a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 77ab8a8b-9cca-4f4a-90c6-a61f8a58f08d |
| 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.193 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.193                      |
| admin_state_up      | True                                 |
| created_at          | 2021-10-08T05:44:49                  |
| id                  | 5fea3980-9dce-4c8b-94e8-dc1fd12d4b18 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f4431102f2d9415590e3ac11c616858a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 77ab8a8b-9cca-4f4a-90c6-a61f8a58f08d |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| ff33cd0e-5f10-4442-9b92-240a2d18c6a5 |      | f4431102f2d9415590e3ac11c616858a | ACTIVE              | 192.168.100.53  |            80 | NO_MONITOR       |      1 |
| 5fea3980-9dce-4c8b-94e8-dc1fd12d4b18 |      | f4431102f2d9415590e3ac11c616858a | ACTIVE              | 192.168.100.193 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

# 外側ネットワークにフローティング IP 作成

root@dlp ~(keystone)#
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2021-10-08T05:46:00Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.212                           |
| floating_network_id | 35816d4c-fa30-4901-8aa5-3749970fa706 |
| id                  | 57d2ecbb-41da-4d49-9e17-e2ff268ff770 |
| name                | 10.0.0.212                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | f4431102f2d9415590e3ac11c616858a     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2021-10-08T05:46:00Z                 |
+---------------------+--------------------------------------+

# ロードバランサーインスタンスの 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.212
# フローティング IP 宛てにアクセスして動作確認

root@dlp ~(keystone)#
curl 10.0.0.212

Web Server on Instance01
root@dlp ~(keystone)#
curl 10.0.0.212

Web Server on Instance02
root@dlp ~(keystone)#
curl 10.0.0.212

Web Server on Instance01
root@dlp ~(keystone)#
curl 10.0.0.212

Web Server on Instance02
関連コンテンツ