IPv6 support
When K2D_ADVERTISE_ADDR is set to an IPv6, the server crash
unable to get advertise IP address: invalid IP address: 2001:db8::1
When k2d_net is created with IPv6 enabled, the assigned IPv6 is not show in the Service.
Also he Service's ipFamilies field is ignored, leading to confusing case where IPv6-only is "requested" and an IPv4 is showed.
$ docker inspect k2d_net
[
{
"Name": "k2d_net",
// ...
"EnableIPv6": true,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.17.2.0/24",
"Gateway": "172.17.2.1"
},
{
"Subnet": "fd7d:a40b:9c6::/64",
"Gateway": "fd7d:a40b:9c6::1/64"
}
]
},
// ...
}
]
$ kubectl get svc my-nginx-svc -o yaml
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: ...
creationTimestamp: "2023-08-10T13:12:31Z"
labels:
app: nginx
name: my-nginx-svc
namespace: default
spec:
clusterIPs:
- 172.17.2.2
ipFamilies:
- IPv6
ipFamilyPolicy: PreferDualStack
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: ClusterIP
status:
loadBalancer: {}
Simply getting the IPAddress and GlobalIPv6Address if not empty and based of the content of ipFamilies can do the trick.
https://github.com/portainer/k2d/blob/4e79c4c944f0b35ab552153a22032cb116391c6b/internal/adapter/converter/service.go#L72
Thanks for the report. We didnt build IPv6 into the Alpha version, but can add this into the Beta... will add to backlog for the Beta.
Btw. Docker IPv6 supports is known to be very buggy https://github.com/moby/moby/issues?q=is%3Aissue+is%3Aopen+ipv6 so I would recommend to wait that libnetwork refactoring work is ready https://github.com/moby/moby/pulls?q=is%3Apr+is%3Aopen+libnetwork because really using IPv6 option but of course support for it can be already implemented in here.