Skip to content

Commit ec3ed1e

Browse files
authored
kubernetes networking model clarifications (#28454)
Amend some clarifications to the kubernetes networking model to deal with some ambiguities, mainly related to the use of NAT and the host-network pods special requirements. xref: https://groups.google.com/g/kubernetes-sig-network/c/m6lwTjKLV8o/m/jM59qEKOBAAJ
1 parent 96feca9 commit ec3ed1e

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

content/en/docs/concepts/cluster-administration/networking.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,46 @@ different approach.
3232

3333
## The Kubernetes network model
3434

35-
Every `Pod` gets its own IP address. This means you do not need to explicitly
36-
create links between `Pods` and you almost never need to deal with mapping
37-
container ports to host ports. This creates a clean, backwards-compatible
38-
model where `Pods` can be treated much like VMs or physical hosts from the
39-
perspectives of port allocation, naming, service discovery, load balancing,
40-
application configuration, and migration.
35+
Every `Pod` gets its own IP address, maximum one per IP family. This means you
36+
do not need need to deal with mapping container ports to host ports in order to
37+
expose the `Pods` services on the network. This creates a clean,
38+
backwards-compatible model where `Pods` can be treated much like VMs or physical
39+
hosts from the perspectives of port allocation, naming, service discovery, load
40+
balancing, application configuration, and migration.
41+
42+
Kubernetes IP addresses exist at the `Pod` scope, in the `status.PodIPs` field
43+
- containers within a `Pod` share their network namespaces - including their IP
44+
address. This means that containers within a `Pod` can all reach each other's
45+
ports on `localhost`. This also means that containers within a `Pod` must
46+
coordinate port usage, but this is no different from processes in a VM. This is
47+
called the _IP-per-pod_ model.
48+
49+
In every cluster, there exists an abstract pod-network to which pods
50+
are connected by default, unless explicitly configured to use the
51+
host-network (on platforms that support it). Even if a host has
52+
multiple IPs, host-network pods only have one Kubernetes IP address at
53+
the `Pod` scope, that is, the `status.PodIPs` field contains one
54+
IP per address family (for now), so the "IP-per-pod" model is guaranteed.
4155

4256
Kubernetes imposes the following fundamental requirements on any networking
4357
implementation (barring any intentional network segmentation policies):
4458

45-
* pods on a node can communicate with all pods on all nodes without NAT
46-
* agents on a node (e.g. system daemons, kubelet) can communicate with all
47-
pods on that node
59+
* any pod-network pod on any node can communicate with all other pod-network
60+
pods on all nodes without NAT.
61+
* non-pod processes on a node (the kubelet, and also for example any other system daemon) can
62+
communicate with all pods on that node.
4863

49-
Note: For those platforms that support `Pods` running in the host network (e.g.
50-
Linux):
64+
In addition, for platforms and runtimes that support running pods in the host OS network:
5165

52-
* pods in the host network of a node can communicate with all pods on all
53-
nodes without NAT
66+
* host-network pods of a node can connect directly with all pods IPs on all
67+
nodes, however, unlike pod-network pods, the source IP address might not be
68+
present in the `Pod` `status.PodIPs` field.
5469

55-
This model is not only less complex overall, but it is principally compatible
56-
with the desire for Kubernetes to enable low-friction porting of apps from VMs
57-
to containers. If your job previously ran in a VM, your VM had an IP and could
58-
talk to other VMs in your project. This is the same basic model.
59-
60-
Kubernetes IP addresses exist at the `Pod` scope - containers within a `Pod`
61-
share their network namespaces - including their IP address and MAC address.
62-
This means that containers within a `Pod` can all reach each other's ports on
63-
`localhost`. This also means that containers within a `Pod` must coordinate port
64-
usage, but this is no different from processes in a VM. This is called the
65-
"IP-per-pod" model.
70+
This model is principally compatible with the desire for Kubernetes to enable
71+
low-friction porting of apps from VMs to containers. If your workload previously ran
72+
in a VM, your VM typically had a single IP address; everything in that VM could talk to
73+
other VMs on your network.
74+
This is the same basic model but less complex overall.
6675

6776
How this is implemented is a detail of the particular container runtime in use. Likewise, the networking option you choose may support [dual-stack IPv4/IPv6 networking](/docs/concepts/services-networking/dual-stack/); implementations vary.
6877

0 commit comments

Comments
 (0)