Ubuntu 22.04
Sponsored Link

OpenStack Antelope : Octavia 利用方法2023/03/28

 
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 クライアントツールをインストールしておきます。
root@dlp ~(keystone)#
apt -y install python3-octaviaclient
[2] Openstack システムを利用可能な任意のユーザーで認証して、ロードバランサーインスタンスを作成します。
作業場所はどこでも良いですが当例では Control ノード上で行います。
ubuntu@dlp ~(keystone)$
openstack subnet list

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| ca5539a8-0291-4684-9fb3-0f448efacebf | public-subnet  | 5352e6c0-47b3-4df2-84f4-ca048f141e1d | 10.0.0.0/24      |
| feb337ec-215e-406e-8871-196fed2c4207 | private-subnet | ce6e88bc-107a-446b-b2ab-255bab7269fe | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2023-03-28T05:31:17                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 4a782b9a-1086-4c40-8fa3-f16a1f52a299 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | e294bd7c00314facacdb46c36fb54ee9     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.253                      |
| vip_network_id      | ce6e88bc-107a-446b-b2ab-255bab7269fe |
| vip_port_id         | 347cf4dc-fc93-47e3-8449-372832723eeb |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | feb337ec-215e-406e-8871-196fed2c4207 |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

ubuntu@dlp ~(keystone)$
openstack loadbalancer list

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

ubuntu@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-03-28T05:33:31                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | d9ac6d87-dfb2-448c-bf96-270438d25e85 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 4a782b9a-1086-4c40-8fa3-f16a1f52a299 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | e294bd7c00314facacdb46c36fb54ee9     |
| 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                        |                                      |
+-----------------------------+--------------------------------------+

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

ubuntu@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-03-28T05:33:53                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 2d3e21e5-1260-471c-96d9-738a1c285499 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | d9ac6d87-dfb2-448c-bf96-270438d25e85 |
| loadbalancers        | 4a782b9a-1086-4c40-8fa3-f16a1f52a299 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | e294bd7c00314facacdb46c36fb54ee9     |
| 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 つのインスタンス

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+
| ID                                   | Name        | Status  | Networks                            | Image      | Flavor    |
+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+
| 9a41a257-a90f-4e34-9551-32b7bf1c2605 | Web02       | ACTIVE  | private=192.168.100.215             | Ubuntu2204 | m1.medium |
| 4b935097-4b38-4bd5-b7ba-632265464d34 | Web01       | ACTIVE  | private=192.168.100.136             | Ubuntu2204 | m1.medium |
| 11987eec-fb38-4de1-a386-3d1d6001bbd3 | Ubuntu-2204 | SHUTOFF | private=10.0.0.252, 192.168.100.100 | Ubuntu2204 | m1.medium |
+--------------------------------------+-------------+---------+-------------------------------------+------------+-----------+

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

ubuntu@dlp ~(keystone)$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.136 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.136                      |
| admin_state_up      | True                                 |
| created_at          | 2023-03-28T05:44:23                  |
| id                  | 0f2ba757-e949-4f97-a250-e4cd04710dd6 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | e294bd7c00314facacdb46c36fb54ee9     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | feb337ec-215e-406e-8871-196fed2c4207 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.215 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.215                      |
| admin_state_up      | True                                 |
| created_at          | 2023-03-28T05:44:42                  |
| id                  | 57e98bf1-5d1b-4e09-a655-e780daec9e32 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | e294bd7c00314facacdb46c36fb54ee9     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | feb337ec-215e-406e-8871-196fed2c4207 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack loadbalancer member list pool01

+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address         | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 0f2ba757-e949-4f97-a250-e4cd04710dd6 |      | e294bd7c00314facacdb46c36fb54ee9 | ACTIVE              | 192.168.100.136 |            80 | NO_MONITOR       |      1 |
| 57e98bf1-5d1b-4e09-a655-e780daec9e32 |      | e294bd7c00314facacdb46c36fb54ee9 | ACTIVE              | 192.168.100.215 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

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

ubuntu@dlp ~(keystone)$
openstack floating ip create public

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2023-03-28T05:45:28Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.245                           |
| floating_network_id | 5352e6c0-47b3-4df2-84f4-ca048f141e1d |
| id                  | d45b7f04-ebcf-4577-932e-da39408af865 |
| name                | 10.0.0.245                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | e294bd7c00314facacdb46c36fb54ee9     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2023-03-28T05:45:28Z                 |
+---------------------+--------------------------------------+

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

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

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

ubuntu@dlp ~(keystone)$
curl 10.0.0.245

Web Server on Instance01
ubuntu@dlp ~(keystone)$
curl 10.0.0.245

Web Server on Instance02
ubuntu@dlp ~(keystone)$
curl 10.0.0.245

Web Server on Instance01
ubuntu@dlp ~(keystone)$
curl 10.0.0.245

Web Server on Instance02
関連コンテンツ