Skip to main content
Networking & service meshLesson 6 of 11

IPv4/IPv6 Dual-Stack Networking

A cluster that hands out both IPv4 and IPv6 addresses. Follow how the control plane, the CNI, Services and DNS each get a second address family, and where applications trip over it. The layers underneath are in Under One Request: TCP/IP Layers.

Pod IPs10.244.1.7
Service IPs10.96.0.0/16 only
DNS answerA
ConnectionIPv4
Dual-stack clusterAPI serverTwo Service CIDRsController mgrTwo Pod CIDRsCNI pluginDual-stack IPAMServiceipFamilyPolicyweb Podstatus.podIPsCoreDNSA + AAAAClient PodHappy eyeballsIPv6 userInternetCloud LBIPv4 + IPv6IPv4-only APIOutside
RequestResponse / reportAppears in a later step

What you will learn

  • Why clusters move to IPv6
  • Which components need two CIDRs, and why the CNI matters
  • ipFamilyPolicy and ipFamilies on a Service
  • A and AAAA records and happy eyeballs in clients
  • IPv6 egress, IPv6-only clusters and load balancers
  • App bugs: IPv4-only listeners and hardcoded parsing

Service ipFamilyPolicy​

ipFamilyPolicyClusterIPsOn a single-stack clusterTypical use
SingleStack (default)One, from the first Service range or the family in ipFamiliesWorksExisting Services, apps not yet tested on IPv6
PreferDualStackTwo when the cluster is dual-stackFalls back to oneMost Services once the app listens on both families
RequireDualStackAlways twoCreation failsServices that must be reachable over both families

Headless Services without a selector that do not set ipFamilyPolicy default to RequireDualStack. The first entry in ipFamilies is the primary family and cannot be changed on an existing Service.

Try it yourself​

kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.spec.podCIDRs}{"\n"}{end}' # One Pod CIDR per family
kubectl get pod <pod> -o jsonpath='{.status.podIPs}' # Two entries on dual-stack
kubectl get svc <svc> -o jsonpath='{.spec.ipFamilyPolicy} {.spec.ipFamilies} {.spec.clusterIPs}'
kubectl patch svc <svc> -p '{"spec":{"ipFamilyPolicy":"PreferDualStack"}}' # Add the second family in place
kubectl run dns-test --rm -it --image=busybox:1.36 --restart=Never -- nslookup -type=AAAA <svc>.<namespace>.svc.cluster.local
kubectl exec <pod> -- ss -ltn # If the image has ss: 0.0.0.0:8080 = IPv4 only, [::]:8080 = IPv6 too

Check yourself

  1. You enable dual-stack on the cluster, but an existing Service still has a single IPv4 ClusterIP. Why?
  2. IPv4 clients reach a dual-stack Service fine, but IPv6 clients get connection refused. What is the most likely cause?
  3. You want an existing Service to become IPv6-primary, with ipFamilies [IPv6, IPv4]. What works?

Further reading: IPv4/IPv6 dual-stack · Validate IPv4/IPv6 dual-stack · RFC 8305 Happy Eyeballs v2 · Service Types (ClusterIP · NodePort · LoadBalancer) · Under One Request: TCP/IP Layers