概要
OpenStackプライベートクラウド環境において、複数の仮想マシンインスタンスを高可用性構成で運用する必要がある場合、VIP(仮想IP)を提供する必要があります。本稿では、Neutronのallowed_address_pairs機能とkeepalivedを組み合わせ、2台の仮想マシンで高可用性を実現する方法を説明します。
ネットワーク構成の確認
まず、現状のネットワーク一覧を確認します。
[root@controller ~]# openstack network list
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+
| id | name | tenant_id | subnets |
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+
| 8f4c2d1e-abcd-4ef5-9ghi-1234567890ab | tenant-net | a2b3c4d5e6f7890123456789abcdef01 | c3d4e5f6-7890-1234-abcd-ef5678901234 172.16.10.0/24 |
| 1a2b3c4d-efgh-5ijk-6lmn-7890abcdef12 | external | a2b3c4d5e6f7890123456789abcdef01 | b4c5d6e7-89ab-cdef-1234-567890abcdef 10.20.30.0/24 |
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+
tenant-net(ID: 8f4c2d1e-abcd-4ef5-9ghi-1234567890ab)を対象ネットワークとして、VIP用のポートを作成します。
VIP用ポートの作成
keepalivedで使用するVIP(172.16.10.200)用のポートを作成します。
[root@controller ~]# openstack port create --network 8f4c2d1e-abcd-4ef5-9ghi-1234567890ab \
--fixed-ip subnet=c3d4e5f6-7890-1234-abcd-ef5678901234,ip-address=172.16.10.200 vip-port
Created a new port:
+-----------------------+-----------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+-----------------------------------------------------------------------------------+
| admin_state_up | True |
| allowed_address_pairs | |
| binding:host_id | |
| binding:profile | {} |
| binding:vif_details | {} |
| binding:vif_type | unbound |
| binding:vnic_type | normal |
| created_at | 2023-05-15T10:30:45Z |
| description | |
| device_id | |
| device_owner | |
| extra_dhcp_opts | |
| fixed_ips | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.200"} |
| id | def56789-abcd-1234-efgh-567890abcdef0 |
| mac_address | fa:16:3e:ab:12:cd |
| name | vip-port |
| network_id | 8f4c2d1e-abcd-4ef5-9ghi-1234567890ab |
| port_security_enabled | True |
| project_id | a2b3c4d5e6f7890123456789abcdef01 |
| revision_number | 1 |
| security_groups | 1a2b3c4d-5678-90ab-cdef-1234567890ab |
| status | DOWN |
| tags | [] |
+-----------------------+-----------------------------------------------------------------------------------+
ポート作成後、バインドされていない状態(unbound)であることが確認できます。次に、このポート情報を仮想マシンに割り当てます。
仮想マシンへのポート割り当て
高可用性を構成する2台の仮想マシンのIPアドレスは、それぞれ172.16.10.50と172.16.10.75です。現在のポート一覧を確認します。
[root@controller ~]# openstack port list
+--------------------------------------+------+--------+----------------------------------+-------------------+
| id | name | tenant_id | mac_address | fixed_ips |
+--------------------------------------+------+--------+----------------------------------+-------------------+
| 12345678-abcd-efgh-1234-567890abcdef | | a2b3c4d5e6f7890123456789abcdef01 | fa:16:3e:11:22:33 | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.1"} |
| 23456789-bcde-fghi-2345-678901bcdefg | | a2b3c4d5e6f7890123456789abcdef01 | fa:16:3e:44:55:66 | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.50"} |
| 34567890-cdef-ghij-3456-789012cdefgh | | a2b3c4d5e6f7890123456789abcdef01 | fa:16:3e:77:88:99 | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.75"} |
| def56789-abcd-1234-efgh-567890abcdef0 | vip-port | a2b3c4d5e6f7890123456789abcdef01 | fa:16:3e:ab:12:cd | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.200"} |
+--------------------------------------+------+--------+----------------------------------+-------------------+
1台目の仮想マシン(172.16.10.50)のポートを更新して、VIP(172.16.10.200)をallowed_address_pairsに追加します。
[root@controller ~]# openstack port update 23456789-bcde-fghi-2345-678901bcdefg \
--allowed-address-pair ip_address=172.16.10.200
Updated port: 23456789-bcde-fghi-2345-678901bcdefg
2台目の仮想マシン(172.16.10.75)のポートも同様に更新します。
[root@controller ~]# openstack port update 34567890-cdef-ghij-3456-789012cdefgh \
--allowed-address-pair ip_address=172.16.10.200
Updated port: 34567890-cdef-ghij-3456-789012cdefgh
更新後のポート情報を確認します。
[root@controller ~]# openstack port show 23456789-bcde-fghi-2345-678901bcdefg
+-----------------------+-----------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+-----------------------------------------------------------------------------------+
| admin_state_up | True |
| allowed_address_pairs | {"ip_address": "172.16.10.200", "mac_address": "fa:16:3e:44:55:66"} |
| binding:host_id | compute-node01 |
| binding:profile | {} |
| binding:vif_details | {"port_filter": true, "datapath_type": "system", "ovs_hybrid_plug": true} |
| binding:vif_type | ovs |
| binding:vnic_type | normal |
| created_at | 2023-05-15T10:25:30Z |
| description | |
| device_id | abcd1234-5678-90ab-cdef-1234567890ab |
| device_owner | compute:nova |
| extra_dhcp_opts | |
| fixed_ips | {"subnet_id": "c3d4e5f6-7890-1234-abcd-ef5678901234", "ip_address": "172.16.10.50"} |
| id | 23456789-bcde-fghi-2345-678901bcdefg |
| mac_address | fa:16:3e:44:55:66 |
| name | |
| network_id | 8f4c2d1e-abcd-4ef5-9ghi-1234567890ab |
| port_security_enabled | True |
| project_id | a2b3c4d5e6f7890123456789abcdef01 |
| revision_number | 8 |
| security_groups | 1a2b3c4d-5678-90ab-cdef-1234567890ab |
| status | ACTIVE |
| tags | [] |
+-----------------------+-----------------------------------------------------------------------------------+
ポート情報にVIP(172.16.10.200)のIPアドレスとMACアドレスが追加されていることが確認できます。
floating IPの関連付け
外部からのアクセスを提供するため、floating IPをVIPポートに関連付けます。これにより、keepalivedが使用するVIPに対して外部からのアクセスが可能になります。