目前,我們已經知道,在多個節點的情況下,OpenStack 不同類型的Netwrok,是如何完成跨節點的通訊。在Day-14: OpenStack Router連接二個Network 我們學到在不同Network上的VM,必需透過Router才能通訊,但之前我們只有看過在單節點的Router行為。 接下來的三天,就要帶大家理解在多節點下,透過Router連接不同的Network類時,VM之間要如何通訊。
今天先來看最簡單,也應該是最常用的一種況,透過Router連接二個Geneve Network. 在OpenStack上建立出來的資源,和Day-14: OpenStack Router連接二個Network基乎是相同的喔,忘記的讀者可以再回去複習一次喔。唯一的差別是,之前是router連接二個local
Network,今天是連接二個geneve
Network。
openstack network create --provider-network-type geneve --provider-segment 100 n1
openstack subnet create --subnet-range 172.16.100.0/24 --network n1 n1subnet
openstack network create --provider-network-type geneve --provider-segment 200 n2
openstack subnet create --subnet-range 192.168.200.0/24 --network n2 n2subnet
openstack server group create --policy affinity odd_affinity
openstack server group create --policy anti-affinity odd_anti_affinity
IMAGE_ID=$(openstack image show cirros --format json | jq -r .id)
AFFINITY_ID=$(openstack server group show odd_affinity --format json | jq -r .id)
ANTI_AFFINITY_ID=$(openstack server group show odd_anti_affinity --format json | jq -r .id)
openstack server create --nic net-id=n1,v4-fixed-ip=172.16.100.10 --flavor m1.nano --image $IMAGE_ID --hint group=$AFFINITY_ID vm_1
openstack server create --nic net-id=n2,v4-fixed-ip=192.168.200.20 --flavor m1.nano --image $IMAGE_ID --hint group=$ANTI_AFFINITY_ID vm_2
openstack server list --long -c Name -c Status -c Host -c "Power State"
+------+--------+-------------+------------+
| Name | Status | Power State | Host |
+------+--------+-------------+------------+
| vm_2 | ACTIVE | Running | compute-02 |
| vm_1 | ACTIVE | Running | compute-01 |
+------+--------+-------------+------------+
openstack router create r
openstack router add subnet r n1subnet
openstack router add subnet r n2subnet
# Network
openstack network list --long -c ID -c "Network Type" | abbrev
+--------+--------------+
| ID | Network Type |
+--------+--------------+
| 76af9b | geneve |
| 4914b0 | geneve |
+--------+--------------+
# Port
openstack port list --long -c ID -c "Fixed IP Addresses" -c "Device Owner" | abbrev
+--------+-------------------------------------------------+--------------------------+
| ID | Fixed IP Addresses | Device Owner |
+--------+-------------------------------------------------+--------------------------+
| 0bece6 | ip_address='172.16.100.10' , subnet_id='ec52a9' | compute:nova |
| 06ff4f | ip_address='172.16.100.2' , subnet_id='ec52a9' | network:distributed |
| 1c52f2 | ip_address='172.16.100.1' , subnet_id='ec52a9' | network:router_interface |
| 8852af | ip_address='192.168.200.20', subnet_id='6f6c62' | compute:nova |
| 21f36b | ip_address='192.168.200.2' , subnet_id='6f6c62' | network:distributed |
| 186849 | ip_address='192.168.200.1', subnet_id='6f6c62' | network:router_interface |
+--------+-------------------------------------------------+--------------------------+
以OVN角度來看,建立出來的logical switch 與 logical router等介紹,也是與Day-14: OpenStack Router連接二個Network相同,大家應該都很熟悉了,忘了可以再回去複習一次喔。
建立二個instances後,二個compute node上bridge的情況。
因為今天的說明不會提及network-controller節點、eth0、eth2,所以我們把這些資訊從圖中省略。
只單看每一個compute node上的bridge,其實就和Day-16: Geneve Tenant Network的介紹是一樣的,差別在於,我們現在是在一個compute node上只有一個vm instance,而且這二個instance都屬於不同的Network。因為在 Compute-02上沒有vm是接在neutron-76af9b
Network上,所以在Compute-02上,就不會有ovnmeta-76af9b
這個namespace;同理,Compute-01上也不會有ovnmeta-4914b0
namespace,這是 OpenStack 採用 localport實現metadata service比較特殊的一個特性。
是不是有發現,OpenStack 採用OVN 建立Network的原理是不是基乎相同呢? 只要前面有看懂,後面都是稍加變型,但也不是非常難理解呢。
我們來看看透過Router連接二個Network,geneve tunnel是如何進行跨節點的封包傳送。和Day-16: Geneve Tenant Network一樣,可以在UDP 6081 port上抓到geneve 封裝後的封包,細看一下封裝的內部封包可以看到:
ICMP request:
ICMP reply:
tcpdump -vvneei eth1 'udp port 6081'
01:51:46.981871 52:54:00:ea:65:ed > 52:54:00:0b:69:b3, ethertype IPv4 (0x0800), length 156: (tos 0x0, ttl 64, id 51590, offset 0, flags [DF], proto UDP (17), length 142)
192.168.33.20.49544 > 192.168.33.30.geneve: [bad udp cksum 0xc40e -> 0x8b54!] Geneve, Flags [C], vni 0x2, proto TEB (0x6558), options [class Open Virtual Networking (OVN) (0x102) type 0x80(C) len 8 data 00030002]
fa:16:3e:79:62:91 > fa:16:3e:e7:10:18, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 63, id 3583, offset 0, flags [DF], proto ICMP (1), length 84)
172.16.100.10 > 192.168.200.20: ICMP echo request, id 6013, seq 1, length 64
01:51:46.983264 52:54:00:0b:69:b3 > 52:54:00:ea:65:ed, ethertype IPv4 (0x0800), length 156: (tos 0x0, ttl 64, id 20670, offset 0, flags [DF], proto UDP (17), length 142)
192.168.33.30.43258 > 192.168.33.20.geneve: [bad udp cksum 0xc40e -> 0xf02c!] Geneve, Flags [C], vni 0x1, proto TEB (0x6558), options [class Open Virtual Networking (OVN) (0x102) type 0x80(C) len 8 data 00030002]
fa:16:3e:6f:80:47 > fa:16:3e:e1:a7:27, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 63, id 22398, offset 0, flags [none], proto ICMP (1), length 84)
192.168.200.20 > 172.16.100.10: ICMP echo reply, id 6013, seq 1, length 64
所以,可以很明確的知道,OVN 不僅將單獨透過geneve做封包的傳送,也會適當的改變內部封包的內容,讓Overlay network上的VM, 認為真的是連接在Overlay 的虛擬網路上。