Dual-Stack IPv4 and IPv6
A cluster runs IPv4 and IPv6 side by side, and one Pod answers on an address of each family. How do Pods and Services get two addresses, which one does a client end up using, and where does each of them lead?
Play the animation 4 steps, animated, plays on a computer or a tablet
Dual-Stack IPv4 and IPv6, step by step
-
Dual-stack is enabled cluster-wide. The API server and controller-manager take an IPv4 and an IPv6 service CIDR, the controller-manager and kube-proxy take both pod CIDRs, and the Kubelet takes a Node IP of each family unless a cloud provider picks them. The CNI has to support both. The Service and Pod still have one address each.
Play from step 1 -
When a Pod is created the CNI allocates one address from each family, an IPv4 out of the v4 pod CIDR and an IPv6 out of the v6 pod CIDR. Both live on one eth0, so client and web both speak either protocol without a second interface.
Play from step 2 -
A Service with ipFamilyPolicy PreferDualStack is given one ClusterIP per family, in the order its ipFamilies list names, here IPv4 then IPv6. Where only one family exists, PreferDualStack falls back to a single ClusterIP and RequireDualStack fails the Service outright.
Play from step 3 -
A client resolving the Service gets an A record and an AAAA record, and which one it dials is its own choice. Both work: the v4 ClusterIP over IPv4 and the v6 ClusterIP over IPv6, each rewritten to the Pod address of that family, and both land on the same Pod.
Play from step 4