CentOS Stream 9
Sponsored Link

OpenStack Bobcat : Octavia 利用方法2023/10/26

 
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 クライアントツールをインストールしておきます。
# Bobcat, EPEL, CRB からインストール

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

+--------------------------------------+----------------+--------------------------------------+------------------+
| ID                                   | Name           | Network                              | Subnet           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 88416326-c3b5-4e6f-bf53-71a77c213721 | private-subnet | 1245127b-0e5c-49c1-8638-de9d51c34949 | 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-10-26T04:08:55                  |
| description         |                                      |
| flavor_id           | None                                 |
| id                  | 28584b93-2ae9-4d30-b29f-242dccc64b12 |
| listeners           |                                      |
| name                | lb01                                 |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| project_id          | f4598dfd3b8a47149234b6892d18d5a4     |
| provider            | amphora                              |
| provisioning_status | PENDING_CREATE                       |
| updated_at          | None                                 |
| vip_address         | 192.168.100.200                      |
| vip_network_id      | 1245127b-0e5c-49c1-8638-de9d51c34949 |
| vip_port_id         | 94845779-8a29-4dd9-a3bd-e7398102f6fa |
| vip_qos_policy_id   | None                                 |
| vip_subnet_id       | 88416326-c3b5-4e6f-bf53-71a77c213721 |
| tags                |                                      |
| additional_vips     | []                                   |
+---------------------+--------------------------------------+

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

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

+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| id                                   | name | project_id                       | vip_address     | provisioning_status | operating_status | provider |
+--------------------------------------+------+----------------------------------+-----------------+---------------------+------------------+----------+
| 28584b93-2ae9-4d30-b29f-242dccc64b12 | lb01 | f4598dfd3b8a47149234b6892d18d5a4 | 192.168.100.200 | 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-10-26T04:13:46                  |
| default_pool_id             | None                                 |
| default_tls_container_ref   | None                                 |
| description                 |                                      |
| id                          | 118a227d-2222-442d-b63e-448231eeafc0 |
| insert_headers              | None                                 |
| l7policies                  |                                      |
| loadbalancers               | 28584b93-2ae9-4d30-b29f-242dccc64b12 |
| name                        | listener01                           |
| operating_status            | OFFLINE                              |
| project_id                  | f4598dfd3b8a47149234b6892d18d5a4     |
| 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                        |                                      |
| hsts_max_age                | None                                 |
| hsts_include_subdomains     | False                                |
| hsts_preload                | False                                |
+-----------------------------+--------------------------------------+

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

[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-10-26T04:14:10                  |
| description          |                                      |
| healthmonitor_id     |                                      |
| id                   | b7295807-276c-4c90-9235-bdf1cef8b436 |
| lb_algorithm         | ROUND_ROBIN                          |
| listeners            | 118a227d-2222-442d-b63e-448231eeafc0 |
| loadbalancers        | 28584b93-2ae9-4d30-b29f-242dccc64b12 |
| members              |                                      |
| name                 | pool01                               |
| operating_status     | OFFLINE                              |
| project_id           | f4598dfd3b8a47149234b6892d18d5a4     |
| 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    |
+--------------------------------------+------------+---------+-------------------------+----------------+-----------+
| cfc120d2-735f-42ca-9d0b-c97ab34c3ac9 | Web02      | ACTIVE  | private=192.168.100.164 | CentOS-Stream9 | m1.medium |
| b8bf6031-01c1-483e-833c-9366756ab1e9 | Web01      | ACTIVE  | private=192.168.100.160 | CentOS-Stream9 | m1.medium |
| 78b8c394-be14-4312-84e8-06eeebbd74f3 | CentOS-St9 | SHUTOFF | private=192.168.100.63  | CentOS-Stream9 | m1.medium |
+--------------------------------------+------------+---------+-------------------------+----------------+-----------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.164                      |
| admin_state_up      | True                                 |
| created_at          | 2023-10-26T04:21:40                  |
| id                  | 4f267b3b-233b-4981-b69d-91accadf3123 |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f4598dfd3b8a47149234b6892d18d5a4     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 88416326-c3b5-4e6f-bf53-71a77c213721 |
| 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.160 --protocol-port 80 pool01

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| address             | 192.168.100.160                      |
| admin_state_up      | True                                 |
| created_at          | 2023-10-26T04:22:01                  |
| id                  | b197f08c-93e8-443c-aae5-b9cc63aa4bdd |
| name                |                                      |
| operating_status    | NO_MONITOR                           |
| project_id          | f4598dfd3b8a47149234b6892d18d5a4     |
| protocol_port       | 80                                   |
| provisioning_status | PENDING_CREATE                       |
| subnet_id           | 88416326-c3b5-4e6f-bf53-71a77c213721 |
| 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 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+
| 4f267b3b-233b-4981-b69d-91accadf3123 |      | f4598dfd3b8a47149234b6892d18d5a4 | ACTIVE              | 192.168.100.164 |            80 | NO_MONITOR       |      1 |
| b197f08c-93e8-443c-aae5-b9cc63aa4bdd |      | f4598dfd3b8a47149234b6892d18d5a4 | ACTIVE              | 192.168.100.160 |            80 | NO_MONITOR       |      1 |
+--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+

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

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2023-10-26T04:22:40Z                 |
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.207                           |
| floating_network_id | 44e70c99-2e15-429b-9dcc-cccaac557c0c |
| id                  | a9993050-feee-44e4-9f4f-8cc6a514954e |
| name                | 10.0.0.207                           |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | f4598dfd3b8a47149234b6892d18d5a4     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2023-10-26T04:22:40Z                 |
+---------------------+--------------------------------------+

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

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

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

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

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

Web Server on Instance02
関連コンテンツ