Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Use default gateway, when bridge network doesn't have it (#666, @kuritka) #666

Merged
merged 1 commit into from
Jul 2, 2021
Merged

[Fix] Use default gateway, when bridge network doesn't have it (#666, @kuritka) #666

merged 1 commit into from
Jul 2, 2021

Conversation

kuritka
Copy link
Contributor

@kuritka kuritka commented Jul 1, 2021

What

If there is no default gateway in the bridge network, k3d crashes because it tries to parse the empty gateway string. This PR will use the default gateway if the gateway does not exist. A cluster can be created than.

Why

For some time docker does not create an automatic gateway in case I create a new network. When I create a bridge network without a gateway and try to connect it to k3d, the cluster installation of the latest versions of k3d crashes.

For example, this won't work for me:

docker network create my-network --subnet=172.18.0.0/16
k3d cluster create my-cluster --network=my-network
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16"
                }
            ]
        },

Screenshot 2021-07-01 at 15 44 09

Right now we have to do something like this manually:

docker network create my-gw-network --subnet=172.22.0.0/16 --gateway=172.22.0.1
k3d cluster create my-cluster --network=my-gw-network
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.22.0.0/16",
                    "Gateway": "172.22.0.1"
                }
            ]
        },

Screenshot 2021-07-01 at 15 54 18
^^^ passing

Implications

our k3d action worked fine on k3d v4.4.1, until 28.6.2021, when the GitHub runner upgraded to Ubuntu Version: 20210628.1. This forced us to upgrade k3d-action a bit earlier than we had planned. Unfortunately, we found out that the newer implementation can't handle the missing gateway. This change does not affect the CLI or Docker settings. It only handles internally the case when the gateway is missing in docker network settings.

@all-contributors add @kuritka for code, maintenance

Signed-off-by: kuritka kuritka@gmail.com

Signed-off-by: kuritka <kuritka@gmail.com>
@iwilltry42
Copy link
Member

Hi @kuritka , thanks for this PR!
Changes in the GH Actions VM may also explain #663.
The addition makes total sense for me, thank you!

@iwilltry42 iwilltry42 self-requested a review July 2, 2021 08:04
@iwilltry42 iwilltry42 self-assigned this Jul 2, 2021
@iwilltry42 iwilltry42 added the enhancement New feature or request label Jul 2, 2021
@iwilltry42 iwilltry42 added this to the v4.4.7 milestone Jul 2, 2021
Copy link
Member

@iwilltry42 iwilltry42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iwilltry42 iwilltry42 changed the title [Fix] Use default gateway, when bridge network doesn't have it (@kuritka) [Fix] Use default gateway, when bridge network doesn't have it (#666, @kuritka) Jul 2, 2021
@iwilltry42 iwilltry42 merged commit cbe187d into k3d-io:main Jul 2, 2021
rancherio-gh-m pushed a commit that referenced this pull request Jul 2, 2021
Author: MichalK <kuritka@gmail.com>
Date:   Fri Jul 2 10:05:26 2021 +0200

    [Fix] Use default gateway, when bridge network doesn't have it (#666, @kuritka)

    Signed-off-by: kuritka <kuritka@gmail.com>
@kuritka kuritka deleted the fix-missing-default-gateway branch July 2, 2021 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants