Network¶
IPv6 only¶
Pods and Services have IPv6 addresses only: no IPv4, no dual stack.
- Services:
ipFamilies: [IPv6](a Service asking for IPv4 is refused). - Servers listen on
::(or[::]), not0.0.0.0; most then accept IPv4-mapped connections too, which never come here. - Going out: an IPv6 destination is reached directly; a name with only an IPv4 address gets a synthesized IPv6
one (DNS64,
64:ff9b::/96) and is reached through NAT64 on the pod's node, every protocol. An IPv4 literal (203.0.113.10in a configuration) isn't reached: use a name, or64:ff9b::203.0.113.10. - The pods' public source addresses are the nodes': an allowlist at a third party lists every node, and changes when servers are replaced (an update replaces them all).
Every pod is denied by default¶
In an application's namespace, a pod can resolve names (DNS, to CoreDNS) and nothing else: it receives no
connection and opens none, to its own namespace's other pods, another namespace, the cluster's services or the
Internet. It declares each flow with a CiliumNetworkPolicy of its namespace:
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata: {name: my-app, namespace: my-app}
spec:
endpointSelector: {matchLabels: {app: my-app}}
ingress:
- fromEntities: [ingress] # the Gateway (Exposing)
toPorts: [{ports: [{port: "8080", protocol: TCP}]}]
- fromEndpoints: [{matchLabels: {app: my-app-worker}}] # this namespace's pods
toPorts: [{ports: [{port: "8080", protocol: TCP}]}]
egress:
- toEndpoints: [{matchLabels: {app: postgres}}] # within the namespace
toPorts: [{ports: [{port: "5432", protocol: TCP}]}]
- toFQDNs: [{matchName: api.example.com}, {matchPattern: "*.example.org"}]
toPorts: [{ports: [{port: "443", protocol: TCP}]}]
- toEntities: [kube-apiserver] # the Kubernetes API
toFQDNsworks because every DNS answer goes through Cilium's DNS proxy: a pod must resolve the name (not an address written in its configuration) for the rule to match.toEntities: [world]opens the Internet (the metadata service stays closed).- A policy selects pods by their labels: give the pods of each component their own label.
- A pod that doesn't start or can't connect, where the same image works elsewhere, usually lacks a rule: its connections time out rather than being refused.
Closed to every pod¶
The cloud's metadata service (169.254.169.254, and its NAT64 address) is denied to every pod by a deny rule no
policy lifts: a pod can't read its server's identity or credentials.
Not for applications¶
hostNetwork pods aren't covered by these policies; they are the cluster's own.