OpenStack Caracal : Octavia 利用方法2024/08/07 |
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)]# dnf --enablerepo=centos-openstack-caracal,epel,crb -y install python3-octaviaclient
|
[2] | Openstack システムを利用可能な任意のユーザーで認証して、ロードバランサーインスタンスを作成します。 作業場所はどこでも良いですが当例では Control ノード上で行います。 |
[cent@dlp ~(keystone)]$ openstack subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | e32f2074-d33b-4b13-9605-1a29301f93a1 | private-subnet | 5bf02aae-1fef-4303-937a-74b8412bf90a | 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 | 2024-08-07T08:03:19 | | description | | | flavor_id | None | | id | f1693481-0e8b-4cea-8b5c-7ad30b2543f8 | | listeners | | | name | lb01 | | operating_status | OFFLINE | | pools | | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | provider | amphora | | provisioning_status | PENDING_CREATE | | updated_at | None | | vip_address | 192.168.100.82 | | vip_network_id | 5bf02aae-1fef-4303-937a-74b8412bf90a | | vip_port_id | fafefd4f-9037-4aff-b04e-f9a644a0afda | | vip_qos_policy_id | None | | vip_subnet_id | e32f2074-d33b-4b13-9605-1a29301f93a1 | | vip_vnic_type | normal | | tags | | | additional_vips | [] | +---------------------+--------------------------------------+ # しばらく時間がたつと [ACTIVE] ステータスになり作成が完了する [cent@dlp ~(keystone)]$ openstack loadbalancer list +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | id | name | project_id | vip_address | provisioning_status | operating_status | provider | +--------------------------------------+------+----------------------------------+----------------+---------------------+------------------+----------+ | f1693481-0e8b-4cea-8b5c-7ad30b2543f8 | lb01 | 03a31c43ede44dcbaacb05c870920e81 | 192.168.100.82 | 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 | 2024-08-07T08:04:40 | | default_pool_id | None | | default_tls_container_ref | None | | description | | | id | dcefe896-ae07-4f6d-85b1-569bced0fe3e | | insert_headers | None | | l7policies | | | loadbalancers | f1693481-0e8b-4cea-8b5c-7ad30b2543f8 | | name | listener01 | | operating_status | OFFLINE | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | 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 | 2024-08-07T08:05:03 | | description | | | healthmonitor_id | | | id | eb3a303b-f98b-4694-82be-6e3424880722 | | lb_algorithm | ROUND_ROBIN | | listeners | dcefe896-ae07-4f6d-85b1-569bced0fe3e | | loadbalancers | f1693481-0e8b-4cea-8b5c-7ad30b2543f8 | | members | | | name | pool01 | | operating_status | OFFLINE | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | 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 | +--------------------------------------+-------+--------+-------------------------+----------------+----------+ | c1092c58-068b-488a-b94e-7a7938d71230 | Web02 | ACTIVE | private=192.168.100.135 | CentOS-Stream9 | m1.small | | 2c97ff74-8465-4b04-bb96-3d657a904377 | Web01 | ACTIVE | private=192.168.100.110 | CentOS-Stream9 | m1.small | +--------------------------------------+-------+--------+-------------------------+----------------+----------+ # 作成したプールのメンバーに加える [cent@dlp ~(keystone)]$ openstack loadbalancer member create --subnet-id private-subnet --address 192.168.100.135 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.135 | | admin_state_up | True | | created_at | 2024-08-07T08:16:06 | | id | 726a8e41-934b-4947-b31a-f2649c09acf9 | | name | | | operating_status | NO_MONITOR | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | e32f2074-d33b-4b13-9605-1a29301f93a1 | | 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.110 --protocol-port 80 pool01 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | address | 192.168.100.110 | | admin_state_up | True | | created_at | 2024-08-07T08:16:24 | | id | 892c7342-79d7-4215-bf2c-7948d37dfa2e | | name | | | operating_status | NO_MONITOR | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | protocol_port | 80 | | provisioning_status | PENDING_CREATE | | subnet_id | e32f2074-d33b-4b13-9605-1a29301f93a1 | | 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 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ | 726a8e41-934b-4947-b31a-f2649c09acf9 | | 03a31c43ede44dcbaacb05c870920e81 | ACTIVE | 192.168.100.135 | 80 | NO_MONITOR | 1 | | 892c7342-79d7-4215-bf2c-7948d37dfa2e | | 03a31c43ede44dcbaacb05c870920e81 | ACTIVE | 192.168.100.110 | 80 | NO_MONITOR | 1 | +--------------------------------------+------+----------------------------------+---------------------+-----------------+---------------+------------------+--------+ # 外側ネットワークにフローティング IP 作成 [cent@dlp ~(keystone)]$ openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2024-08-07T08:17:19Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.203 | | floating_network_id | cedf14f5-e8ef-4577-a226-022f289f45fb | | id | af23c6a0-3d9b-47ee-9b23-dcc8d57dbeef | | name | 10.0.0.203 | | port_details | None | | port_id | None | | project_id | 03a31c43ede44dcbaacb05c870920e81 | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2024-08-07T08:17:19Z | +---------------------+--------------------------------------+ # ロードバランサーインスタンスの 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.203
# フローティング IP 宛てにアクセスして動作確認 [cent@dlp ~(keystone)]$ curl 10.0.0.203 Web Server on Instance01 [cent@dlp ~(keystone)]$ curl 10.0.0.203 Web Server on Instance02 [cent@dlp ~(keystone)]$ curl 10.0.0.203 Web Server on Instance01 [cent@dlp ~(keystone)]$ curl 10.0.0.203 Web Server on Instance02 |
Sponsored Link |
|