CentOS Stream 8
Sponsored Link

OpenStack Xena : Octavia 利用方法2021/11/25

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

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 61bf3654-bef1-4ddd-8d23-f2fd41166f4e | public-subnet  | ac8911e7-afd7-4913-997e-2f0412f1271b | 10.0.0.0/24      |
| 9724f8a3-4c59-4d7d-9838-82bc682a551c | private-subnet | 3adf0a70-6446-4095-916d-17d9f753bbe6 | 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-11-25T00:26:11                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 5a52749c-95e5-49c5-a034-431a5721b4af |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | b12f95625664420ca31949963b75b74f     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.220                      |
| vip_network_id      | 3adf0a70-6446-4095-916d-17d9f753bbe6 |
| vip_port_id         | 7710dbbd-00fc-40eb-8c7e-eaa447abf52c |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | 9724f8a3-4c59-4d7d-9838-82bc682a551c |
| tags                |                                      |
+---------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| 5a52749c-95e5-49c5-a034-431a5721b4af | lb01 | b12f95625664420ca31949963b75b74f | 192.168.100.220 | 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-11-25T00:29:01                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 8df57f4f-bcd0-46df-aafd-fdd77e81fa02 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 5a52749c-95e5-49c5-a034-431a5721b4af |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | b12f95625664420ca31949963b75b74f     |
| 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-11-25T00:29:24                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 537b409b-1ccf-475d-b009-106b802d5891 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 8df57f4f-bcd0-46df-aafd-fdd77e81fa02 |
| loadbalancers        | 5a52749c-95e5-49c5-a034-431a5721b4af |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | b12f95625664420ca31949963b75b74f     |
| 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   |
+--------------------------------------+-------+--------+------------------------+-----------------+----------+
| 267da02c-056a-4678-9d49-c19c802a2cde | Web02 | ACTIVE | private=192.168.100.78 | CentOS-Stream-8 | m1.small |
| ff35a3bb-d2cd-4c01-9960-a34c6cb5a5a2 | Web01 | ACTIVE | private=192.168.100.44 | CentOS-Stream-8 | m1.small |
+--------------------------------------+-------+--------+------------------------+-----------------+----------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.78                       |
| admin_state_up      | True                                 |
| created_at          | 2021-11-25T00:34:38                  |
| id                  | 48df21bb-b8d6-4af2-a6c8-64400cddc518 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | b12f95625664420ca31949963b75b74f     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 9724f8a3-4c59-4d7d-9838-82bc682a551c |
| 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.44 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.44                       |
| admin_state_up      | True                                 |
| created_at          | 2021-11-25T00:34:51                  |
| id                  | b2d1f0e0-af04-48c6-a6a7-11323081d683 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | b12f95625664420ca31949963b75b74f     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 9724f8a3-4c59-4d7d-9838-82bc682a551c |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+
| 48df21bb-b8d6-4af2-a6c8-64400cddc518 |      | b12f95625664420ca31949963b75b74f | ACTIVE              | 192.168.100.78 |            80 | NO_MONITOR       |      1 |
| b2d1f0e0-af04-48c6-a6a7-11323081d683 |      | b12f95625664420ca31949963b75b74f | ACTIVE              | 192.168.100.44 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+----------------+---------------+------------------+--------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2021-11-25T00:42:32Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.253                           |
| floating_network_id | ac8911e7-afd7-4913-997e-2f0412f1271b |
| id                  | 30ef7fe3-b45b-4182-a8ad-7331e005d7df |
| name                | 10.0.0.253                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | b12f95625664420ca31949963b75b74f     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2021-11-25T00:42:32Z                 |
+---------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
curl 10.0.0.253

Web Server on Instance01
[root@dlp ~(keystone)]#
curl 10.0.0.253

Web Server on Instance02
[root@dlp ~(keystone)]#
curl 10.0.0.253

Web Server on Instance01
[root@dlp ~(keystone)]#
curl 10.0.0.253

Web Server on Instance02
関連コンテンツ