Dual-stack in Kubernetes allows for simultaneous support of both IPv4 and IPv6 communication within a cluster. This allows you to deploy services and applications that can seamlessly communicate using either protocol, depending on network configuration and availability. Enabling dual-stack involves configuring the networking components of the cluster, such as the networking plugin (e.g., Calico), responsible for routing and network connectivity. With dual-stack enabled, Kubernetes pods can be assigned both IPv4 and IPv6 addresses.
It’s worth noting that enabling dual-stack in Kubernetes necessitates appropriate network infrastructure support, including IPv6 connectivity across cluster nodes. Furthermore, individual applications running within the pods must be compatible with both IPv4 and IPv6 protocols to benefit from dual-stack capabilities.
Dual-stack offers several advantages, including:
- Seamless interoperability between IPv4 and IPv6 devices.
- Gradual adoption of IPv6 without disrupting existing IPv4 connectivity.
- Support for legacy applications and services that rely on IPv4.
- Ability to leverage the larger address space and other benefits of IPv6 while maintaining connectivity with IPv4 networks.
By default, MicroK8s nodes use a single IPv4 stack. Setting up the network in a Kubernetes cluster is a complex task, and the choice between single or dual-stack functionality can only be made during the initial installation of each node. The process for making this selection is described in the “How to configure network CIDRs and dual-stack” guide, and involves configuring a launch configuration that is considered during the installation of the MicroK8s snap.
As described in the upstream docs, a dual-stack cluster Kubernetes services can have endpoints that are either IPv4, IPv6, or a combination of both. To specify the desired stack, you can use the .spec.ipFamilyPolicy
field with one of the following values:
- SingleStack: This indicates a single-stack service. The control plane assigns a cluster IP for the service using the first configured service cluster IP range.
- PreferDualStack: This option allocates both IPv4 and IPv6 cluster IPs for the service. It allows for endpoints in both address families, but these are not enforced.
- RequireDualStack: With this setting, the service
.spec.ClusterIPs
are allocated from both the IPv4 and IPv6 address ranges. It ensures that endpoints are available in both stacks.
Further reading:
- Upstream IPv4/IPv6 dual-stack documentation IPv4/IPv6 dual-stack | Kubernetes
- How to configure network CIDRs and dual-stack