Currently Kubernetes services are created in single stack mode by default, defaulting to primary address family of the cluster.
This is a mutating webhook admission controller that adds ipFamilyPolicy: PreferDualStack
to all newly created services if the field is not explicitely specified, making dual-stack the default.
kubectl apply -f https://raw.githubusercontent.com/tibordp/prefer-dual-stack-webhook/master/deploy.yaml
Before | Afrer |
---|---|
> kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: dummy
spec:
selector:
app: dummy
ports:
- port: 80
targetPort: 80
EOF
service/dummy created
> kubectl describe svc dummy
Name: dummy
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=dummy
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.96.200.4
IPs: 10.96.200.4
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: <none>
Session Affinity: None
Events: <none> |
> kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: dummy
spec:
selector:
app: dummy
ports:
- port: 80
targetPort: 80
EOF
service/dummy created
> kubectl describe svc dummy
Name: dummy
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=dummy
Type: ClusterIP
IP Family Policy: PreferDualStack
IP Families: IPv4,IPv6
IP: 10.96.19.47
IPs: 10.96.19.47,fd00:10:96::f31
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: <none>
Session Affinity: None
Events: <none> |
Admission controller webhook boilerplate adapted from douglasmakey/admissioncontroller by Douglas Makey Mendez Molero.