Senior LevelDocker & Deployment
How do Dual-Stack IPv4/IPv6 Kubernetes clusters route native IPv6 traffic?
❓ Interview Prompt: Explain Kubernetes dual-stack configuration, dual-stack pod/service addressing, IPv6 service endpoints, and CNI plugin requirements.
IPv6 address space exhaustion is driving adoption of dual-stack Kubernetes — pods and services receive both an IPv4 and IPv6 address simultaneously.
Kubernetes Dual-Stack Architecture:
•
Both IPv4 and IPv6 pod CIDRs configured:
--cluster-cidr=10.244.0.0/16,fd00:10:244::/56•
Both IPv4 and IPv6 service CIDRs:
--service-cluster-ip-range=10.96.0.0/12,fd00:10:96::/112•
Each pod gets: one IPv4 (
10.244.1.5) AND one IPv6 (fd00:10:244::5) address.•
Each Service gets: one IPv4 ClusterIP AND one IPv6 ClusterIP.
IP Family Policy (Service-Level):
•
SingleStack: Service uses only the primary IP family.•
PreferDualStack: Use dual-stack if cluster supports it, single otherwise.•
RequireDualStack: Fail if cluster doesn't support dual-stack.Why Dual-Stack:
1
ISP IPv6 requirements: Many cloud providers allocate IPv6 CIDR blocks.
2
End-to-end IPv6: Direct IPv6 routing from client to pod — no NAT overhead.
3
Regulatory compliance: Some government networks require native IPv6.
4
Future-proofing: IPv4 allocation pools are exhausted in many regions.
CNI Requirements:
Dual-stack requires CNI plugins that support both address families. Calico, Cilium, and Flannel all support dual-stack. Each plugin must allocate and manage both IPv4 and IPv6 addresses from their respective pools.
Code Implementation Example
yaml
# Service with explicit dual-stack configuration
apiVersion: v1
kind: Service
metadata:
name: api-dual-stack
spec:
selector:
app: api
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: RequireDualStack
ports:
- port: 80
targetPort: 3000
type: ClusterIP
# Resulting service will have two ClusterIPs:
# kubectl get svc api-dual-stack
# NAME TYPE CLUSTER-IP CLUSTER-IP-V6 PORT(S)
# api-dual-stack ClusterIP 10.96.45.123 fd00:10:96::1234 80/TCP
---
# NetworkPolicy for dual-stack: works the same — applies to both address families
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-netpol
spec:
podSelector:
matchLabels:
app: api
policyTypes: [Ingress]
ingress:
- from:
- ipBlock:
cidr: "2001:db8::/32" # Allow specific IPv6 CIDR💡Dual-stack Service: ipFamilies specifies both IPv4+IPv6, ipFamilyPolicy: RequireDualStack allocates two ClusterIPs.
🎯 Interview Key Takeaway
Kubernetes dual-stack assigns both IPv4 and IPv6 addresses to pods and services simultaneously. Configure ipFamilyPolicy on Services; requires CNI plugins supporting both address families.
#Kubernetes#Dual-Stack#IPv6#Networking#IP Addressing#Senior
Back to all Docker & Deployment Questions→