Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

networking: gateway in network configuration does not set default route #862

Closed
steveej opened this issue May 4, 2015 · 7 comments
Closed

Comments

@steveej
Copy link
Contributor

steveej commented May 4, 2015

I'm running a pod having the following network defined:

{
    "name": "containers_ipv4",
    "type": "macvlan",
    "master": "enp0s20u1u1",
    "mode": "bridge",
    "ipam": {
            "type": "host-local",
            "subnet": "192.168.2.0/24",
            "gateway": "192.168.2.254"
    }
}

I would expect the defined gateway to be the default gateway on that interface, but that is not the case.
What would be the pros and cons of doing so?

@jonboulle
Copy link
Contributor

@eyakubovich should we move this to cni?

@eyakubovich
Copy link
Contributor

The defined gateway should be the gateway on the 192.168.2.0/24 route, not default. However that doesn't work as well. Moving this to CNI.

@eyakubovich
Copy link
Contributor

@steveej My previous comment doesn't make much sense. However the behavior is as designed: ipam.gateway is a somewhat of a wart -- it just says that there is this gateway but it does not say that's the gateway for the default route. The default route has to be specified explicitly:

"ipam": {
    "type": "host-local",
    "subnet": "192.168.2.0/24",
    "routes": [
        { "dst": "0.0.0.0/0", "gw": "192.168.2.254" }
    ]
}

On the other hand, if "gateway" was specified, "gw" can be dropped:

"ipam": {
    "type": "host-local",
    "subnet": "192.168.2.0/24",
    "gateway": "192.168.2.254"
    "routes": [
        { "dst": "0.0.0.0/0" }
    ]
}

Why the complexity? It helps to look at what IPAM plugin returns: "ip", "gateway", and "routes". The main plugin uses "gateway" for things like setting an IP on the bridge (turning it into a gateway), if requested. And it will also use that value if "gw" is missing on the route. In case of "host-local", ipam.gateway configuration value just gets passed back in the result.

I will admit that it is confusing but it does allow for many use cases.

@alban alban removed this from the v0.8.0 milestone Jul 15, 2015
@jonboulle jonboulle added this to the v0.10.0 milestone Oct 8, 2015
@jonboulle
Copy link
Contributor

@steveej @eyakubovich what's the solution here, better documentation?

@jonboulle jonboulle modified the milestones: v0.11.0, v0.10.0 Oct 20, 2015
@alban
Copy link
Member

alban commented Nov 12, 2015

any news on this?

@alban alban modified the milestones: v0.12.0, v0.11.0 Nov 13, 2015
@steveej
Copy link
Contributor Author

steveej commented Nov 21, 2015

This topic is still undecided in CNI. The tendency goes towards a new IPAM boolean attribute named similar to "gatewayIsDefault". IPAM would then generate the default route and pass it along.

@alban alban modified the milestones: v0.13.0, v0.12.0, v0.14.0 Nov 26, 2015
@alban alban modified the milestones: v0.16.0, v0.15.0 Jan 7, 2016
@alban alban modified the milestones: v1.0.0, v0.16.0 Jan 20, 2016
@iaguis iaguis added this to the v1+ milestone Jan 26, 2016
@iaguis iaguis removed this from the v1.0.0 milestone Jan 26, 2016
@steveej
Copy link
Contributor Author

steveej commented Jul 25, 2016

In general the behavior remains as is, but the bridge plugin received a new 'isDefaultGateway' attribute for convenience.

@steveej steveej closed this as completed Jul 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants