CentOS Stream 8
Sponsored Link

OpenStack Victoria : Octavia 利用方法
2021/03/26
 
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           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 63c29d7b-e870-477d-819b-e5dfe41af1d0 | public-subnet  | ea9725cf-a8bc-4eb5-a374-7d7d0e11453c | 10.0.0.0/24      |
| 94afb0cc-1d58-4615-8fef-8852271bfc16 | private-subnet | 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 | 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-03-25T07:40:09                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | c0c736f4-19cf-49fb-8929-3be1a4be0fa2 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | b9bf51c6436a4c5aa7a2df05688afb49     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.52                       |
| vip_network_id      | 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 |
| vip_port_id         | 477c07ee-a521-47a1-8591-7cb0b7e48bd5 |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | 94afb0cc-1d58-4615-8fef-8852271bfc16 |
+---------------------+--------------------------------------+

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

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

+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address    | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| c0c736f4-19cf-49fb-8929-3be1a4be0fa2 | lb01 | b9bf51c6436a4c5aa7a2df05688afb49 | 192.168.100.52 | 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-03-25T07:42:38                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 0bb16cd7-41f0-4847-915a-ebf083e34a42 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | c0c736f4-19cf-49fb-8929-3be1a4be0fa2 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | b9bf51c6436a4c5aa7a2df05688afb49     |
| 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           | 2021-03-25T07:43:02                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 71ea3911-1b81-404c-b547-a209ae39e0b9 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 0bb16cd7-41f0-4847-915a-ebf083e34a42 |
| loadbalancers        | c0c736f4-19cf-49fb-8929-3be1a4be0fa2 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | b9bf51c6436a4c5aa7a2df05688afb49     |
| 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   |
+--------------------------------------+-------+--------+-------------------------+-----------------+----------+
| 2c9582b9-1797-45b2-add8-68785d1be283 | Web02 | ACTIVE | private=192.168.100.74  | CentOS-Stream-8 | m1.small |
| 92bf24c1-a8f5-41df-8f10-ea7f58184696 | Web01 | ACTIVE | private=192.168.100.144 | CentOS-Stream-8 | m1.small |
+--------------------------------------+-------+--------+-------------------------+-----------------+----------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.74                       |
| admin_state_up      | True                                 |
| created_at          | 2021-03-25T07:53:01                  |
| id                  | fa6d0183-722c-41c1-8820-5d28c99779b1 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | b9bf51c6436a4c5aa7a2df05688afb49     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 94afb0cc-1d58-4615-8fef-8852271bfc16 |
| 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.144 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.144                      |
| admin_state_up      | True                                 |
| created_at          | 2021-03-25T07:53:17                  |
| id                  | 4b396d5a-4ad5-472b-9c13-ffcf562d856d |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | b9bf51c6436a4c5aa7a2df05688afb49     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 94afb0cc-1d58-4615-8fef-8852271bfc16 |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| fa6d0183-722c-41c1-8820-5d28c99779b1 |      | b9bf51c6436a4c5aa7a2df05688afb49 | ACTIVE              | 192.168.100.74  |            80 | NO_MONITOR       |      1 |
| 4b396d5a-4ad5-472b-9c13-ffcf562d856d |      | b9bf51c6436a4c5aa7a2df05688afb49 | ACTIVE              | 192.168.100.144 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2021-03-25T07:53:50Z                 |
| description         |                                      |
| dns_domain          | None                                 |
| dns_name            | None                                 |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.229                           |
| floating_network_id | ea9725cf-a8bc-4eb5-a374-7d7d0e11453c |
| id                  | fb51e61d-1233-4f94-8268-04abc632fe0d |
| name                | 10.0.0.229                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | b9bf51c6436a4c5aa7a2df05688afb49     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2021-03-25T07:53: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.229
# フローティング IP 宛てにアクセスして動作確認

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

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

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

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

Web Server on Instance02
関連コンテンツ