Skip to content

Commit a813812

Browse files
committed
better docs!
1 parent 551a7d9 commit a813812

File tree

2 files changed

+153
-1
lines changed

2 files changed

+153
-1
lines changed

docs/chi_edge/networking.md

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,125 @@ While Neutron is still running, it is only used for floating IPs, and end-users
66

77
Instead, the Calico CNI plugin for kubernetes is managing most networking, and all container -> container networking, and neutron and zun are configured to provide a minimal "shim" around this.
88

9+
## Network Details
10+
11+
### Openstack's Perspective
12+
As far as Openstack knows, there are only two networks, "Public" and "Caliconet", connected by a router.
13+
14+
This router is implemented by means of a linux network namespace, openvswitch ports (qg_iface and qr_iface) which map layer 2 traffic into that namespace, and a series of IPTables rules which configure routing between qg_iface and qr_iface.
15+
By default, the `qg_iface` acts as the default route within the namespace, and other links (each a separare qr_iface) route to their local subnets.
16+
For technical details, refer to [Neutron's Layer 3 Internals](https://docs.openstack.org/neutron/latest/contributor/internals/layer3.html)
17+
18+
```mermaid
19+
flowchart LR
20+
21+
public[public \n 129.114.34.128/25]
22+
caliconet[caliconet \n 192.168.64.0/18]
23+
24+
public --- qg_iface
25+
subgraph qrouter_ns[Router Namespace]
26+
qg_iface[qg_iface \n 129.114.34.129/32 \n 129.114.34.130/32]
27+
qg_iface-- L3 Routing --- qr_iface
28+
qr_iface[qr_iface \n 192.168.64.1/18]
29+
30+
note[net.ipv4.ip_forward = 1
31+
default via 129.114.34.129 dev qg_iface
32+
129.114.34.128/25 dev qg_iface
33+
192.168.64.0/16 dev qr_iface
34+
]
35+
end
36+
qr_iface --- caliconet
37+
```
38+
When a floating IP is attached, neutron binds that address to `qg_iface` in the router namespace, and also sets up NAT to forward traffic to the mapped internal address.
39+
40+
We'll refer to the external address as `floating_ip`, and the internal one as `fixed_ip`.
41+
```mermaid
42+
sequenceDiagram
43+
remote->>qg_iface: source=foo dest=floating_ip
44+
qg_iface->>qr_iface: DNAT: source=foo dest=fixed_ip
45+
qr_iface->>host: source=foo dest=fixed_ip
46+
host->>qr_iface: source=fixed_ip dest=foo
47+
qr_iface->>qg_iface: SNAT: source=floating_ip dest=foo
48+
qg_iface->>remote: source=floating_ip dest=foo
49+
```
50+
51+
1. Initially, a packet arriving from outside has some `source_address=foo`, and `destination_address=floating_ip`.
52+
2. It arrives at qg_iface, and iptables applies "destination nat (DNAT)" to rewrite the destination IP address. Now, `source_address=foo` and `destination_address=fixed_ip`
53+
3. As `destination_address=fixed_ip`, the routing table indicates it should be forwarded via `qr_iface`, and it's sent off into caliconet
54+
4. If a host were listening on `fixed_ip`, and connected to `caliconet` at layer 2, it would receive this packet and be able to respond. Its reply would have `source_address=fixed_ip` and `destination_address=foo`.
55+
5. On the way back out, the packet would be received at `qr_iface`, and IPtables apply source NAT (SNAT), rewriting `source_address=fixed_ip` to `source_address=floating_ip`
56+
6. the packet then leaves via `qg_iface`, having `source_address=floating_ip`,`destination_address=foo`, and is routed back to the intiial sender.
57+
58+
59+
### Calico's Perspective
60+
61+
Calico sees the world differently, and is primarily concerned about routing between kubernetes hosts. Using the below diagram, we'll look at how traffic flows between a few different pairs of endpoints.
62+
63+
```mermaid
64+
flowchart LR
65+
66+
67+
clusternet[Cluster Network 10.3.0.0/24]
68+
clusternet --- localip1
69+
clusternet --- localip2
70+
clusternet --- gw[Gateway:
71+
10.3.0.1/24
72+
10.8.8.1/24
73+
]
74+
75+
subgraph host2[Kubernetes Host 2]
76+
localip2[Local IP 2\n 10.3.0.12/24]---podcidr2
77+
subgraph podcidr2[PodCIDR 192.168.72.0/24]
78+
pod2a[Pod2a 192.168.72.12]
79+
pod2b[Pod2b 192.168.72.13]
80+
end
81+
note2[
82+
0.0.0.0/0 via 10.3.0.1
83+
192.168.71.0/24 via 10.3.0.11
84+
192.168.72.0/24 via 10.3.0.12
85+
]
86+
end
87+
subgraph host1[Kubernetes Host 1]
88+
localip1[Local IP 1\n 10.3.0.11/24]---podcidr1
89+
subgraph podcidr1[PodCIDR: 192.168.71.0/24]
90+
pod1a[Pod1a 192.168.71.10]
91+
pod1b[Pod1b 192.168.71.11]
92+
end
93+
note1[
94+
0.0.0.0/0 via 10.3.0.1
95+
192.168.71.0/24 via 10.3.0.11
96+
192.168.72.0/24 via 10.3.0.12
97+
]
98+
end
99+
subgraph "outside"
100+
gw --- external[external 10.8.8.8/24]
101+
note3[Route: 0.0.0.0/0 via 10.8.8.1]
102+
end
103+
```
104+
105+
We start with the assumption that Local IP 1 and Local IP 2 can communicate directly with each other at layer 2, as it's the simplest.
106+
107+
* Traffic between two pods on the same host, or between the host's local IP and its own pods, is sent directly with no NAT or encapsulation.
108+
* Traffic from pods on one host to the local IP of another host (or other "endpoints" calico is aware of), is also sent directly, as the source and destination addresses still match the locally connected routes. (Depending on config, it could also be routed via local-ip)
109+
* Traffic from pods on one host to pods on another host is routed, using the destination host's "local ip" as the next-hop
110+
* in contrast, traffic from pods to the "outside" has source NAT applied before leaving the host, since the network outside of Calico wouldn't be aware of how to return traffic to the pod IPs.
111+
112+
| Source | Destination | Method |
113+
|----------------------|---------------------------|------------|
114+
| Pod1a 192.168.71.10 | Pod1b 192.168.71.10 | Forwarded |
115+
| Pod1a 192.168.71.10 | Host1 10.3.0.11 | Fwd/Routed |
116+
| Pod1a 192.168.71.10 | Host2 10.3.0.11 | Fwd/Routed |
117+
| Pod1a 192.168.71.10 | Pod2a 192.168.73.12 | Routed |
118+
| Pod1a 192.168.71.10 | "outside" 10.8.8.8 | SNAT + Routed |
119+
120+
121+
122+
123+
124+
### Connecting them together
125+
9126

10127

11-
## Network Architecture
12128

13129
```mermaid
14130
flowchart LR
@@ -35,6 +151,39 @@ flowchart LR
35151
neutron-router-- N:192.168.0.1/16 \n C:192.168.0.2/16 --- calico-node
36152
```
37153

154+
155+
```mermaid
156+
157+
flowchart TD
158+
159+
160+
161+
subgraph edge-device
162+
subgraph podcidr2
163+
pod2[pod2 \n 192.168.9.0/24] --- eth4
164+
165+
end
166+
pod2 --- local-ip2
167+
local-ip2[local-ip2 wg spoke \n 10.3.0.9]
168+
end
169+
170+
subgraph edge-device3
171+
subgraph podcidr3
172+
pod3[pod3 \n 192.168.10.0/24]
173+
end
174+
pod3 --- local-ip3
175+
local-ip3[local-ip3 wg spoke \n 10.3.0.10]
176+
177+
end
178+
179+
local-ip2 --- wireguard-hub[hub 10.3.0.2]
180+
local-ip3 --- wireguard-hub
181+
182+
ssh --- wireguard-hub
183+
184+
```
185+
186+
38187
All neutron "sees" is that some addresses in the "calico-subnet" send traffic, respond to messages, and so on.
39188
Calico's BGP routing handles getting ipv4 traffic from neutron to the actual destination, which may traverse multiple kubnernetes nodes before reaching a container.
40189

site-config/inventory/02-kolla-hosts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,9 @@ ovn-database
727727
[ovn-sb-db:children]
728728
ovn-database
729729

730+
[k3s:children]
731+
control
732+
730733
[doni:children]
731734
control
732735

0 commit comments

Comments
 (0)