OpenStack Zed : Neutron ネットワークを構成する (Geneve)2022/10/07 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、Geneve カプセル化によるネットワークを構成します。
事前に以下のように Control ノード、 Network ノード、 Compute ノードの 各サービスノードを構築済みであることが前提です。
また、当例では Network ノードと Compute ノードが 2 つのネットワークインターフェースを持っているものとします。
また、下例で eth1 の方は IP なしでインターフェースを UP しています。 IP なしでのインターフェース UP の設定はこちらの [1] を参照ください。 ------------+-----------------------------+-----------------------------+------------ | | | 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 | | OVN Metadata Agent | | | | | | OVN-Controller | +-----------------------+ +----------+------------+ +----------+------------+ eth1|(UP with no IP) eth1|(UP with no IP) |
[1] | Network ノードと Compute ノードの両方でブリッジマッピングを設定しておきます。 |
# ブリッジ作成 (名称は任意) root@network:~# ovs-vsctl add-br br-eth1
# 追加したブリッジのポートに [eth1] を追加 # [eth1] は環境によって異なるため自身の環境に置き換え root@network:~# ovs-vsctl add-port br-eth1 eth1
# ブリッジと [physnet1] をマッピング ([physnet1] の名称は任意) root@network:~# ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet1:br-eth1 |
[2] | 仮想ルーターを作成します。作業場所はどこでもよいですが、当例では Control ノード上で作業します。 |
root@dlp ~(keystone)# openstack router create router01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2022-10-07T06:54:02Z | | description | | | enable_ndp_proxy | None | | external_gateway_info | null | | flavor_id | None | | id | 4ba6195a-2ada-49f0-87dd-2dcb366fb661 | | name | router01 | | project_id | 231a529f51394426b07c56f2c5ec580e | | revision_number | 0 | | routes | | | status | ACTIVE | | tags | | | tenant_id | 231a529f51394426b07c56f2c5ec580e | | updated_at | 2022-10-07T06:54:02Z | +-------------------------+--------------------------------------+ |
[3] | 内部用のネットワークを作成し、仮想ルーターに関連付けます。 |
# 内部用ネットワーク作成 root@dlp ~(keystone)# openstack network create private --provider-network-type geneve +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2022-10-07T06:54:25Z | | description | | | dns_domain | None | | id | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | is_vlan_transparent | None | | mtu | 1442 | | name | private | | port_security_enabled | True | | project_id | 231a529f51394426b07c56f2c5ec580e | | provider:network_type | geneve | | provider:physical_network | None | | provider:segmentation_id | 55128 | | qos_policy_id | None | | revision_number | 1 | | router:external | Internal | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2022-10-07T06:54:25Z | +---------------------------+--------------------------------------+ # 内部用ネットワークにサブネット作成 root@dlp ~(keystone)# openstack subnet create private-subnet --network private \ --subnet-range 192.168.100.0/24 --gateway 192.168.100.1 \ --dns-nameserver 10.0.0.10 +----------------------+--------------------------------------+ | Field | Value | +----------------------+--------------------------------------+ | allocation_pools | 192.168.100.2-192.168.100.254 | | cidr | 192.168.100.0/24 | | created_at | 2022-10-07T06:55:14Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | True | | gateway_ip | 192.168.100.1 | | host_routes | | | id | a454cf3e-fef5-46f6-8468-4a26cbd14983 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | private-subnet | | network_id | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | | project_id | 231a529f51394426b07c56f2c5ec580e | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2022-10-07T06:55:14Z | +----------------------+--------------------------------------+ # 仮想ルーターに内部ネットワークを設定 root@dlp ~(keystone)# openstack router add subnet router01 private-subnet
|
[4] | 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。 |
# 外部用ネットワーク作成 root@dlp ~(keystone)# openstack network create \ --provider-physical-network physnet1 \ --provider-network-type flat --external public +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2022-10-07T06:55:51Z | | description | | | dns_domain | None | | id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | is_vlan_transparent | None | | mtu | 1500 | | name | public | | port_security_enabled | True | | project_id | 231a529f51394426b07c56f2c5ec580e | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 1 | | router:external | External | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2022-10-07T06:55:51Z | +---------------------------+--------------------------------------+ # 外部用ネットワークにサブネット作成 root@dlp ~(keystone)# openstack subnet create public-subnet \ --network public --subnet-range 10.0.0.0/24 \ --allocation-pool start=10.0.0.200,end=10.0.0.254 \ --gateway 10.0.0.1 --dns-nameserver 10.0.0.10 --no-dhcp +----------------------+--------------------------------------+ | Field | Value | +----------------------+--------------------------------------+ | allocation_pools | 10.0.0.200-10.0.0.254 | | cidr | 10.0.0.0/24 | | created_at | 2022-10-07T06:56:24Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | False | | gateway_ip | 10.0.0.1 | | host_routes | | | id | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | public-subnet | | network_id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | project_id | 231a529f51394426b07c56f2c5ec580e | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2022-10-07T06:56:24Z | +----------------------+--------------------------------------+ # 仮想ルーターにゲートウェイを設定 root@dlp ~(keystone)# openstack router set router01 --external-gateway public |
[5] | 作成したネットワークは、外部用はデフォルトで全プロジェクトがアクセス可能ですが、内部用はデフォルトでは [admin] プロジェクトのみがアクセス可能なため、内部ネットワークを利用させたいプロジェクトにアクセス権限を付与しておきます。 |
# ネットワーク RBAC リスト表示 root@dlp ~(keystone)# openstack network rbac list +--------------------------------------+-------------+--------------------------------------+ | ID | Object Type | Object ID | +--------------------------------------+-------------+--------------------------------------+ | d83c31e1-4f57-4cb9-89f7-57f98462971d | network | 394ec727-7e9a-473e-8068-45aa841a9ac2 | +--------------------------------------+-------------+--------------------------------------+ # RBAC の詳細 # [access_as_external] のみ全プロジェクトがアクセス可能な状態 root@dlp ~(keystone)# openstack network rbac show d83c31e1-4f57-4cb9-89f7-57f98462971d +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | action | access_as_external | | id | d83c31e1-4f57-4cb9-89f7-57f98462971d | | object_id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | object_type | network | | project_id | 231a529f51394426b07c56f2c5ec580e | | target_project_id | * | +-------------------+--------------------------------------+ # 作成済みネットワーク一覧 root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 394ec727-7e9a-473e-8068-45aa841a9ac2 | public | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | private | a454cf3e-fef5-46f6-8468-4a26cbd14983 | +--------------------------------------+---------+--------------------------------------+ # 作成済みプロジェクト一覧 root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 231a529f51394426b07c56f2c5ec580e | admin | | 4dd1e1f6bac441ff9c77002c3ab4c58a | hiroshima | | ee51c09c765e4a4d958c2bcc4dbb5665 | service | +----------------------------------+-----------+ # [private] への [access_as_shared] アクセス権を [hiroshima] プロジェクトに付与 root@dlp ~(keystone)# netID=$(openstack network list | grep private | awk '{ print $2 }') root@dlp ~(keystone)# prjID=$(openstack project list | grep hiroshima | awk '{ print $2 }') root@dlp ~(keystone)# openstack network rbac create --target-project $prjID --type network --action access_as_shared $netID +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | action | access_as_shared | | id | dbfc766a-ae2e-422e-92ef-2d31736012bc | | object_id | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | | object_type | network | | project_id | 231a529f51394426b07c56f2c5ec580e | | target_project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | +-------------------+--------------------------------------+ |
[6] | 内部ネットワークへのアクセス権を付与したプロジェクトに所属する任意のユーザーでログインし、 作成した内部ネットワークをインスタンスに関連付けてインスタンスを作成/起動します。 |
# 利用可能な [flavor] 確認 ubuntu@dlp ~(keystone)$ openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ # 利用可能なイメージ確認 ubuntu@dlp ~(keystone)$ openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 126bc335-fc00-478d-b84a-a9e79eba2574 | Ubuntu2204 | active | +--------------------------------------+------------+--------+ # 利用可能なネットワーク確認 ubuntu@dlp ~(keystone)$ openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 394ec727-7e9a-473e-8068-45aa841a9ac2 | public | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | private | a454cf3e-fef5-46f6-8468-4a26cbd14983 | +--------------------------------------+---------+--------------------------------------+ # インスタンス用のセキュリティグループを作成 ubuntu@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+-----------------------------------------------------------------------+ | Field | Value | +-----------------+-----------------------------------------------------------------------+ | created_at | 2022-10-07T07:00:25Z | | description | secgroup01 | | id | 8757368a-e07f-494f-9fc3-f3c19d79d1d9 | | name | secgroup01 | | project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | | revision_number | 1 | | rules | created_at='2022-10-07T07:00:25Z', direction='egress', ethertype='... | | | created_at='2022-10-07T07:00:25Z', direction='egress', ethertype='... | | stateful | True | | tags | [] | | updated_at | 2022-10-07T07:00:25Z | +-----------------+-----------------------------------------------------------------------+ # インスタンス接続用の SSH キーペア作成 ubuntu@dlp ~(keystone)$ ssh-keygen -q -N "" Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): # 公開鍵登録 ubuntu@dlp ~(keystone)$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | created_at | None | | fingerprint | 19:32:5a:d9:ae:43:3d:01:74:1a:96:dc:b2:5a:e5:ff | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | 9345b7f4de21427abf31ad308cf952f8 | +-------------+-------------------------------------------------+ubuntu@dlp ~(keystone)$ netID=$(openstack network list | grep private | awk '{ print $2 }')
ubuntu@dlp ~(keystone)$
ubuntu@dlp ~(keystone)$ openstack server create --flavor m1.small --image Ubuntu2204 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu-2204
openstack server list +--------------------------------------+-------------+--------+-------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-------------------------+------------+----------+ | a456ee32-b105-4c5e-8eae-ddccb48f913e | Ubuntu-2204 | ACTIVE | private=192.168.100.187 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-------------------------+------------+----------+ |
[7] | 作成した仮想マシンインスタンスにフローティング IP を割り当てます。 |
ubuntu@dlp ~(keystone)$ openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2022-10-07T07:02:12Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.228 | | floating_network_id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | id | 73d6a792-0d8c-4225-a5ea-70cdec92e189 | | name | 10.0.0.228 | | port_details | None | | port_id | None | | project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2022-10-07T07:02:12Z | +---------------------+--------------------------------------+
ubuntu@dlp ~(keystone)$
openstack server add floating ip Ubuntu-2204 10.0.0.228
# 設定確認 ubuntu@dlp ~(keystone)$ openstack floating ip show 10.0.0.228 +---------------------+--------------------------------------------------------------------------+ | Field | Value | +---------------------+--------------------------------------------------------------------------+ | created_at | 2022-10-07T07:02:12Z | | description | | | dns_domain | | | dns_name | | | fixed_ip_address | 192.168.100.187 | | floating_ip_address | 10.0.0.228 | | floating_network_id | 394ec727-7e9a-473e-8068-45aa841a9ac2 | | id | 73d6a792-0d8c-4225-a5ea-70cdec92e189 | | name | 10.0.0.228 | | port_details | admin_state_up='True', device_id='a456ee32-b105-4c5e-8eae-ddccb48f913... | | port_id | 73b28cfb-6cd8-45d6-8cb4-c9a6a67eb67e | | project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | | qos_policy_id | None | | revision_number | 2 | | router_id | 4ba6195a-2ada-49f0-87dd-2dcb366fb661 | | status | ACTIVE | | subnet_id | None | | tags | [] | | updated_at | 2022-10-07T07:02:43Z | +---------------------+--------------------------------------------------------------------------+ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ | a456ee32-b105-4c5e-8eae-ddccb48f913e | Ubuntu-2204 | ACTIVE | private=10.0.0.228, 192.168.100.187 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ |
[8] | 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。 |
# ICMP 許可 ubuntu@dlp ~(keystone)$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2022-10-07T07:04:12Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 4b9c9684-7f23-4c5a-9c1b-eb2847d799c1 | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | | protocol | icmp | | remote_address_group_id | None | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 8757368a-e07f-494f-9fc3-f3c19d79d1d9 | | tags | [] | | updated_at | 2022-10-07T07:04:12Z | +-------------------------+--------------------------------------+ # SSH 許可 ubuntu@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2022-10-07T07:04:45Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 3cd092ae-96d3-4bc9-baaa-98f7446653ad | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 4dd1e1f6bac441ff9c77002c3ab4c58a | | protocol | tcp | | remote_address_group_id | None | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 8757368a-e07f-494f-9fc3-f3c19d79d1d9 | | tags | [] | | updated_at | 2022-10-07T07:04:45Z | +-------------------------+--------------------------------------+ubuntu@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | 3cd092ae-96d3-4bc9-baaa-98f7446653ad | tcp | IPv4 | 0.0.0.0/0 | 22:22 | ingress | None | None | | 4b9c9684-7f23-4c5a-9c1b-eb2847d799c1 | icmp | IPv4 | 0.0.0.0/0 | | ingress | None | None | | 57a5294c-db7f-44fe-9cac-0ff45a483e9d | None | IPv4 | 0.0.0.0/0 | | egress | None | None | | dd310d5a-3b1e-4c4f-9bcf-f9ace255e264 | None | IPv6 | ::/0 | | egress | None | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ |
[9] | 仮想マシンインスタンスに割りあてられたフローティング IP 宛てに SSH 接続することで、インスタンスに SSH ログインできます。 |
ubuntu@dlp ~(keystone)$ openstack server list +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ | a456ee32-b105-4c5e-8eae-ddccb48f913e | Ubuntu-2204 | ACTIVE | private=10.0.0.228, 192.168.100.187 | Ubuntu2204 | m1.small | +--------------------------------------+-------------+--------+-------------------------------------+------------+----------+ubuntu@dlp ~(keystone)$ ssh ubuntu@10.0.0.228 The authenticity of host '10.0.0.228 (10.0.0.228)' can't be established. ED25519 key fingerprint is SHA256:21mw83UaW4a/qkEvhewPgA1Lw+J4jdu+dAEmfsOyH4E. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.0.0.228' (ED25519) to the list of known hosts. Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-48-generic x86_64) ..... ..... To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. ubuntu@ubuntu-2204:~$ # ログインできた |
Sponsored Link |
|