Debian 12 bookworm
Sponsored Link

OpenStack Zed : Octavia 利用方法2023/06/30

 
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  |  |  Neutron L2/L3 Agent  |  |        Libvirt        |
|  Memcached  Nginx     |  |   Neutron Metadata    |  |      Nova Compute     |
|  Keystone   httpd     |  |     Open vSwitch      |  |    Neutron L2 Agent   |
|  Glance     Nova API  |  |     iSCSI Target      |  |      Open vSwitch     |
|  Neutron Server       |  |     Cinder Volume     |  |                       |
|  Neutron Metadata     |  |    Octavia Services   |  |                       |
|  Cinder API           |  |        Nginx          |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

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

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 | private-subnet | ae5fdb1f-efb9-412b-9053-b81106c90336 | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| availability_zone   | None                                 |
| created_at          | 2023-06-30T01:34:10                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 599003a5-35a5-4d1e-8f60-250121beb7c0 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.171                      |
| vip_network_id      | ae5fdb1f-efb9-412b-9053-b81106c90336 |
| vip_port_id         | 5a74fec6-7455-4dd5-baca-3cd13b6aa80f |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

debian@dlp ~(keystone)$
openstack loadbalancer list

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

debian@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-06-30T01:35:43                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 8651a761-d663-488b-a5f0-4e69ff783755 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 599003a5-35a5-4d1e-8f60-250121beb7c0 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| 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                        |                                      |
+-----------------------------+--------------------------------------+

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

debian@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-06-30T01:36:07                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | 7ddd7f61-92e4-451b-b7c1-6ea79800b743 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 8651a761-d663-488b-a5f0-4e69ff783755 |
| loadbalancers        | 599003a5-35a5-4d1e-8f60-250121beb7c0 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| 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 つのインスタンス

debian@dlp ~(keystone)$
openstack server list

+--------------------------------------+-----------+---------+------------------------------------+----------+-----------+
| ID                                   | Name      | Status  | Networks                           | Image    | Flavor    |
+--------------------------------------+-----------+---------+------------------------------------+----------+-----------+
| e7a9befb-e6ed-4523-9014-b0ccca522d05 | Web02     | ACTIVE  | private=192.168.100.196            | Debian12 | m1.medium |
| 2beaca03-d1a7-4317-9258-fe4acc401ab7 | Web01     | ACTIVE  | private=192.168.100.18             | Debian12 | m1.medium |
| c3a4a792-a7ac-41bd-8c93-7fd162016f22 | Debian-12 | SHUTOFF | private=10.0.0.241, 192.168.100.66 | Debian12 | m1.medium |
+--------------------------------------+-----------+---------+------------------------------------+----------+-----------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.196                      |
| admin_state_up      | True                                 |
| created_at          | 2023-06-30T01:39:13                  |
| id                  | 189ea6ca-ee34-469d-b33c-f56b306be9dd |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.18                       |
| admin_state_up      | True                                 |
| created_at          | 2023-06-30T01:39:32                  |
| id                  | 102ef5c8-b30f-47ee-9578-96eb6bea2890 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 |
| updated_at          | None                                 |
| weight              | 1                                    |
| monitor_port        | None                                 |
| monitor_address     | None                                 |
| backup              | False                                |
| tags                |                                      |
+---------------------+--------------------------------------+

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

+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| id                                   | name | project_id                       | provisioning_status | address         | protocol_port | operating_status | weight |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 189ea6ca-ee34-469d-b33c-f56b306be9dd |      | 1c2f5dc8c4f9494fbaaa4217c8e3585a | ACTIVE              | 192.168.100.196 |            80 | NO_MONITOR       |      1 |
| 102ef5c8-b30f-47ee-9578-96eb6bea2890 |      | 1c2f5dc8c4f9494fbaaa4217c8e3585a | ACTIVE              | 192.168.100.18  |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2023-06-30T01:44:07Z                 |
| description         |                                      |
| dns_domain          | None                                 |
| dns_name            | None                                 |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.254                           |
| floating_network_id | b9b8536b-0696-4a5b-af05-602587435c0a |
| id                  | b9a07664-3dc6-473b-9f87-f17ea6f0d03a |
| name                | 10.0.0.254                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | 1c2f5dc8c4f9494fbaaa4217c8e3585a     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2023-06-30T01:44:07Z                 |
+---------------------+--------------------------------------+

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

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

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

debian@dlp ~(keystone)$
curl 10.0.0.254

Web Server on Instance01
debian@dlp ~(keystone)$
curl 10.0.0.254

Web Server on Instance02
debian@dlp ~(keystone)$
curl 10.0.0.254

Web Server on Instance01
debian@dlp ~(keystone)$
curl 10.0.0.254

Web Server on Instance02
関連コンテンツ