Ubuntu 20.04
Sponsored Link

OpenStack Ussuri : Octavia 利用方法2020/06/16

 
OpenStack Load Balancing as a Service(Octavia)の利用方法です。
当例では以下のような環境を例に Octavia をインストールしています。
ネットワーク環境は、こちらのリンク先の通り VXLAN タイプのネットワークを構成しています
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |        L2 Agent       |   |        Libvirt        |
|  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
|  Nova API             |   |    Octavia Services   |   |                       |
|  Neutron Server       |   |                       |   |                       |
|  Metadata Agent       |   |                       |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] ロードバランサーインスタンスを作成します。デフォルトでは [admin] 権限のユーザーのみがインスタンス作成可能です。作業場所はどこでも良いですが当例では Control ノード上で行います。
root@dlp ~(keystone)#
openstack subnet list

+--------------------------------------+---------+--------------------------------------+------------------+
| ID                                   | Name    | Network                              | Subnet           |
+--------------------------------------+---------+--------------------------------------+------------------+
| ddfcdd10-7ecb-4239-b3d7-46fdd15a006d | subnet2 | 1f3f1f9b-4822-4312-b5a5-51a529cd6e8a | 10.0.0.0/24      |
| e2a461fc-9d50-4bab-913f-14067b175ea6 | subnet1 | b351e1b9-bd7c-4e3c-b5eb-848d211f4392 | 192.168.100.0/24 |
+--------------------------------------+---------+--------------------------------------+------------------+

root@dlp ~(keystone)#
openstack loadbalancer create --name lb01 --vip-subnet-id subnet1

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2020-06-16T02:17:05                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | ca8087f4-09f2-4721-9415-6449cada783e |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.204                      |
| vip_network_id      | b351e1b9-bd7c-4e3c-b5eb-848d211f4392 |
| vip_port_id         | d5fd42f5-0a00-4d27-ba9d-767000b39a61 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | e2a461fc-9d50-4bab-913f-14067b175ea6 |
+---------------------+--------------------------------------+

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

root@dlp ~(keystone)#
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+-----------------+---------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+----------+
| ca8087f4-09f2-4721-9415-6449cada783e | lb01 | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | 192.168.100.204 | ACTIVE              | 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-06-16T02:30:40                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 259bcbd7-d75e-4ab5-a6ed-7e818ccab2c3 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | ca8087f4-09f2-4721-9415-6449cada783e |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e     |
| 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                                 |
+-----------------------------+--------------------------------------+

# 作成したリスナーにプール作成

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-06-16T02:31:33                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 9cdd0c16-0d71-4f09-880e-b72d9f005ab0 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 259bcbd7-d75e-4ab5-a6ed-7e818ccab2c3 |
| loadbalancers        | ca8087f4-09f2-4721-9415-6449cada783e |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e     |
| 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                                 |
+----------------------+--------------------------------------+

# Web サーバーが稼働する二つのインスタンス

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+---------------+--------+------------------------+------------+----------+
| ID                                   | Name          | Status | Networks               | Image      | Flavor   |
+--------------------------------------+---------------+--------+------------------------+------------+----------+
| 10de2817-7f1e-4e54-a4a4-68110579bb30 | Ubuntu_2004-2 | ACTIVE | int_net=192.168.100.37 | Ubuntu2004 | m1.small |
| 5d817687-8a25-4888-b99f-50ecd7139747 | Ubuntu_2004-1 | ACTIVE | int_net=192.168.100.77 | Ubuntu2004 | m1.small |
+--------------------------------------+---------------+--------+------------------------+------------+----------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.37                       |
| admin_state_up      | True                                 |
| created_at          | 2020-06-16T02:42:43                  |
| id                  | e94ea373-cf6c-46d8-97d5-f764a2d78322 |
| name                |                                      |
| operating_status    | OFFLINE                              |
| project_id          | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | e2a461fc-9d50-4bab-913f-14067b175ea6 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
+---------------------+--------------------------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.77                       |
| admin_state_up      | True                                 |
| created_at          | 2020-06-16T02:42:51                  |
| id                  | bda12685-40c2-40ff-8072-3ed8d183489a |
| name                |                                      |
| operating_status    | OFFLINE                              |
| project_id          | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | e2a461fc-9d50-4bab-913f-14067b175ea6 |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+
| e94ea373-cf6c-46d8-97d5-f764a2d78322 |      | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | ACTIVE              | 192.168.100.37 |            80 | OFFLINE          |      1 |
| bda12685-40c2-40ff-8072-3ed8d183489a |      | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | ACTIVE              | 192.168.100.77 |            80 | OFFLINE          |      1 |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+

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

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

+---------------------+-----------------------------------------------------------------------------+
| Field               | Value                                                                       |
+---------------------+-----------------------------------------------------------------------------+
| created_at          | 2020-06-16T02:43:50Z                                                        |
| description         |                                                                             |
| dns_domain          | None                                                                        |
| dns_name            | None                                                                        |
| fixed_ip_address    | None                                                                        |
| floating_ip_address | 10.0.0.226                                                                  |
| floating_network_id | 1f3f1f9b-4822-4312-b5a5-51a529cd6e8a                                        |
| id                  | 56cf03c9-cdf1-42d2-ae17-ef0bad8ec9e3                                        |
| location            | Munch({'cloud': '', 'region_name': '', 'zone': None, 'project': Munch({'... |
| name                | 10.0.0.226                                                                  |
| port_details        | None                                                                        |
| port_id             | None                                                                        |
| project_id          | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e                                            |
| qos_policy_id       | None                                                                        |
| revision_number     | 0                                                                           |
| router_id           | None                                                                        |
| status              | DOWN                                                                        |
| subnet_id           | None                                                                        |
| tags                | []                                                                          |
| updated_at          | 2020-06-16T02:43:50Z                                                        |
+---------------------+-----------------------------------------------------------------------------+

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

root@dlp ~(keystone)#
curl 10.0.0.226

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

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

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

Web Server on Instance02
関連コンテンツ