Dual-Stack IPv4 and IPv6

What changes when a cluster runs IPv4 and IPv6 side by side? The CNI gives each Pod it wires one address per family on the same eth0, and a Service set to ipFamilyPolicy PreferDualStack gets one ClusterIP per family, ordered by ipFamilies. Where only one family exists, PreferDualStack falls back to a single ClusterIP while RequireDualStack fails the Service outright. A client resolves both A and AAAA records and connects over whichever family it prefers.

Play the animation 4 steps, animated, best on a wide screen

Dual-Stack IPv4 and IPv6, Kubernetes diagram

Dual-Stack IPv4 and IPv6, step by step

  1. 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, the Kubelet takes a Node IP of each family unless a cloud provider picks them, and the CNI has to support both. The Service and Pod still have one address each.

    Play from step 1
  2. When the 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 the same eth0, so the Pod speaks either protocol without a second interface.

    Play from step 2
  3. 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
  4. 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

Sources