CentOS Stream 9
Sponsored Link

OpenStack Antelope : Octavia 利用方法2023/04/20

 
OpenStack Load Balancing as a Service(Octavia)の利用方法です。
当例では以下のような環境を例に Octavia をインストールしています。
------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |    Octavia Services   |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] Octavia クライアントツールをインストールしておきます。
# Antelope, EPEL, CRB からインストール

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-antelope,epel,crb -y install python3-octaviaclient
[2] Openstack システムを利用可能な任意のユーザーで認証して、ロードバランサーインスタンスを作成します。
作業場所はどこでも良いですが当例では Control ノード上で行います。
[cent@dlp ~(keystone)]$
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| bd8d7602-95e4-4540-971e-a0104dd8b658 | private-subnet | 913ec733-5a60-4df0-b182-49a393675bca | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

[cent@dlp ~(keystone)]$
openstack loadbalancer create --name lb01 --vip-subnet-id private-subnet

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2023-04-20T00:16:05                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | ae91be56-804c-4fda-b17d-b11b2371cc88 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | 40aa0807595447f0bd8d5b2dbfa1839b     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.64                       |
| vip_network_id      | 913ec733-5a60-4df0-b182-49a393675bca |
| vip_port_id         | a0c2397b-2123-4bf2-ae9a-e2132996af3b |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | bd8d7602-95e4-4540-971e-a0104dd8b658 |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack loadbalancer list

+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address    | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
| ae91be56-804c-4fda-b17d-b11b2371cc88 | lb01 | 40aa0807595447f0bd8d5b2dbfa1839b | 192.168.100.64 | ACTIVE              | OFFLINE          | amphora  |
+--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+
[3] ロードバランサーインスタンスにリスナーやメンバーを追加して、バックエンドの Web サーバーが稼働する 2 つのインスタンスをラウンドロビンで負荷分散するよう設定します。
# TCP 80 をリスンするリスナーを作成

[cent@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                  | 2023-04-20T00:18:00                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 97ac9f57-3204-486d-9661-e35199d06cfc |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | ae91be56-804c-4fda-b17d-b11b2371cc88 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | 40aa0807595447f0bd8d5b2dbfa1839b     |
| 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                        |                                      |
+-----------------------------+--------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack loadbalancer pool create --name pool01 --lb-algorithm ROUND_ROBIN --listener listener01 --protocol TCP

+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| admin_state_up       | True                                 |
| created_at           | 2023-04-20T00:18:24                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 376ff833-4838-4d45-af4a-5593eddcdf72 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 97ac9f57-3204-486d-9661-e35199d06cfc |
| loadbalancers        | ae91be56-804c-4fda-b17d-b11b2371cc88 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | 40aa0807595447f0bd8d5b2dbfa1839b     |
| 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 つのインスタンス

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+------------+---------+-------------------------------------+----------------+-----------+
| ID                                   | Name       | Status  | Networks                            | Image          | Flavor    |
+--------------------------------------+------------+---------+-------------------------------------+----------------+-----------+
| 6aa3410d-6f43-4c50-9b4e-51193e86f3cb | Web02      | ACTIVE  | private=192.168.100.86              | CentOS-Stream9 | m1.small  |
| f299a117-41f4-41c2-828a-9fe0daae0d58 | Web01      | ACTIVE  | private=192.168.100.188             | CentOS-Stream9 | m1.small  |
| 284a5b69-7b76-49c3-8180-c9b22284d429 | CentOS-St9 | SHUTOFF | private=10.0.0.229, 192.168.100.140 | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+---------+-------------------------------------+----------------+-----------+

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

[cent@dlp ~(keystone)]$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.86 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.86                       |
| admin_state_up      | True                                 |
| created_at          | 2023-04-20T00:24:24                  |
| id                  | b0e909a9-73fc-4885-891a-c484273dba69 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 40aa0807595447f0bd8d5b2dbfa1839b     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | bd8d7602-95e4-4540-971e-a0104dd8b658 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.188 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.188                      |
| admin_state_up      | True                                 |
| created_at          | 2023-04-20T00:24:42                  |
| id                  | 474ea35b-8ea1-49ca-8d1a-1e4ca70772f0 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 40aa0807595447f0bd8d5b2dbfa1839b     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | bd8d7602-95e4-4540-971e-a0104dd8b658 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack loadbalancer member list pool01

+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address         | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| b0e909a9-73fc-4885-891a-c484273dba69 |      | 40aa0807595447f0bd8d5b2dbfa1839b | ACTIVE              | 192.168.100.86  |            80 | NO_MONITOR       |      1 |
| 474ea35b-8ea1-49ca-8d1a-1e4ca70772f0 |      | 40aa0807595447f0bd8d5b2dbfa1839b | ACTIVE              | 192.168.100.188 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

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

[cent@dlp ~(keystone)]$
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2023-04-20T00:25:24Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.224                           |
| floating_network_id | c1c6a4c6-776e-4c4f-b557-b9efc4a43ee8 |
| id                  | cfc36f0b-4305-47dd-b471-53ae43a903f8 |
| name                | 10.0.0.224                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | 40aa0807595447f0bd8d5b2dbfa1839b     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2023-04-20T00:25:24Z                 |
+---------------------+--------------------------------------+

# ロードバランサーインスタンスの VIP とフローティング IP を関連付ける

[cent@dlp ~(keystone)]$
VIPPORT=$(openstack loadbalancer show lb01 | grep vip_port_id | awk {'print $4'})

[cent@dlp ~(keystone)]$
openstack floating ip set --port $VIPPORT 10.0.0.224
# フローティング IP 宛てにアクセスして動作確認

[cent@dlp ~(keystone)]$
curl 10.0.0.224

Web Server on Instance01
[cent@dlp ~(keystone)]$
curl 10.0.0.224

Web Server on Instance02
[cent@dlp ~(keystone)]$
curl 10.0.0.224

Web Server on Instance01
[cent@dlp ~(keystone)]$
curl 10.0.0.224

Web Server on Instance02
関連コンテンツ