Closed ololobus closed 2 years ago
It looks like k3d
cannot figure out the host ip address in the specified subnet, so it cannot define host.k3d.internal
alias.
Hi @ololobus , thanks for opening this issue!
This is an edge case I haven't seen yet, but I'll look into this!
I guess k3d should at least fail if it cannot determine the correct address to use there :thinking:
So somehow the network created via docker-compose doesn't seem to have the gateway set correctly? :thinking:
Can you give more details on your setup? Or post the output of docker network inspect zenith_net
?
I can try to reproduce this later for debugging purposes.
I am seeing the same issue with 5.3.0 (not observed in 5.2.2). I setup the network via a docker cli command:
docker network create <name> --driver=bridge -o "com.docker.network.driver.mtu"="1450" --subnet=172.20.0.0/16
My k3d config uses values in that IP range for cluster cidr, service cidr, and cluster dns (in addition to --network <name>
).
So somehow the network created via docker-compose doesn't seem to have the gateway set correctly?
@iwilltry42, it seems it has, here is an output of docker network inspect zenith_net
:
[
{
"Name": "zenith_net",
"Id": "3c4221a7591171eb42dde89802e1ea13945daf1a1443039eddc9a166cfa2c467",
"Created": "2022-03-16T18:29:42.962296627+03:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.20.42.0/24",
"Gateway": "172.20.42.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"6ee06f6c34f22f504c45d15dbebaa7c85256425bba760a7abd0f9d46a443c82b": {
"Name": "young-forest-671487",
"EndpointID": "d709edd51058e1fff125d3affcd5c72d1e8e5fb7a410135e70e2f18be7ec4553",
"MacAddress": "02:42:ac:14:2a:04",
"IPv4Address": "172.20.42.4/24",
"IPv6Address": ""
},
"b4d0bcd4f3c7c455880bb0f4b35903e3a3f90898a4d1b1228966077043f273bf": {
"Name": "royal-bread-675489",
"EndpointID": "9380eb4de34b963aba754fec6df3ca63cbc221345ac9d852339d4428d63bcbef",
"MacAddress": "02:42:ac:14:2a:02",
"IPv4Address": "172.20.42.2/24",
"IPv6Address": ""
},
"e75f9e40f5242447ba30ae2edc832480337cf126ce4439bb6fd29496d59d16fb": {
"Name": "misty-block-624433",
"EndpointID": "7f3623d90beb838ef6ee15db457701639966057cb0b31208fb036ef7d9538a99",
"MacAddress": "02:42:ac:14:2a:03",
"IPv4Address": "172.20.42.3/24",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "zenith_net",
"com.docker.compose.project": "console",
"com.docker.compose.version": "1.27.4"
}
}
]
This is weird.. I just tried your commands and in fact in my setup, the gateway is missing :thinking:
$ docker network create foonet --driver=bridge -o "com.docker.network.driver.mtu"="1450" --subnet=172.20.0.0/16
ab0aac890c2fd5ec4c41ea64c73305dfdf5e5a7ea752e8e15bd671ce503b0587
$ docker network inspect foonet
[
{
"Name": "foonet",
"Id": "ab0aac890c2fd5ec4c41ea64c73305dfdf5e5a7ea752e8e15bd671ce503b0587",
"Created": "2022-03-23T16:39:21.843406633+01:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.20.0.0/16"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.driver.mtu": "1450"
},
"Labels": {}
}
]
UPDATE: Supplying the --gateway
flag when creating the network fixes it, e.g. --gateway 172.20.0.1
. I guess there's a similar option for the compose spec. Also, according to some google results, restarting docker will add some default gateway to the network (no clue why it's not there from the start) :thinking:
Ugh, my network describing was misleading, as it was from my local machine, when attaching the existing network in k3d worked fine. Also I've surely restarted Docker daemon after the network creation.
Yeah, for docker-compose
there is a gateway
option as well, so the config should look like:
networks:
zenith_net:
name: zenith_net
ipam:
config:
- subnet: "172.20.42.0/24"
gateway: 172.20.42.1
I'll try watching the gateway value and maybe try to run with and without it in CI.
k3d should now error out if there's no gateway defined, as it's a hard requirement to set host.k3d.internal, where host.docker.internal is not present.
I guess your main issue is fixed by setting the gateway IP, but feel free to reopen this if you need further work from k3d's side :+1:
Thanks for the followup @iwilltry42 thats a good find - will have to set that on my end when making the docker network.
What did you do
I have a Docker network
zenith_net
which is created bydocker-compose
using the following config:Then I try to create a cluster:
And get an error:
It first reproduced a couple of times on my local machine, but the problem disappeared after reboot. And now it is stably reproducible in GitHub Actions CI.
What did you expect to happen
Cluster is created without errors.
Screenshots or terminal output
Which OS & Architecture
Linux x86_64:
Pop!_OS 21.10
Ubuntu 20.04.4 LTS
Which version of
k3d
Locally and in CI:
Which version of docker
Locally:
In CI: