-
Notifications
You must be signed in to change notification settings - Fork 228
Improve the CNI implementation, and documentation #308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, very welcome changes! ✨
Some nits, otherwise LGTM 👍
**Cons:** | ||
|
||
- **docker-dependent**: By design, this mode is can only be used with docker, and is hence not portable across container runtimes. | ||
- **No multi-node support**: The IP is local (in the `172.17.0.0/16` range), and hence other computers can't connect to your VM's IP address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This IP range differs from the one given above, I believe this one here (172.17.0.0/16
) is correct and the one above should be changed.
pkg/network/docker/docker.go
Outdated
} | ||
|
||
func GetDockerNetworkPlugin(r runtime.Interface) (network.Plugin, error) { | ||
return &dockerNetworkPlugin{r}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to return an error?
IP: result.IPAddress, | ||
Mask: net.IPv4Mask(255, 255, 0, 0), | ||
}, | ||
Gateway: net.IPv4(result.IPAddress[0], result.IPAddress[1], result.IPAddress[2], 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TODO to make this configurable/auto-retrievable if someone has changed their gateway?
pkg/network/cni/cni.go
Outdated
@@ -162,22 +163,46 @@ func (plugin *cniNetworkPlugin) Status() error { | |||
return plugin.checkInitialized() | |||
} | |||
|
|||
func (plugin *cniNetworkPlugin) SetupContainerNetwork(containerid string) error { | |||
func (plugin *cniNetworkPlugin) PrepareContainerSpec(container *runtime.ContainerConfig) error { | |||
// we will handle the networking on our own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we -> We
pkg/operations/start.go
Outdated
} | ||
|
||
log.Infof("Networking is handled by %s", networkPlugin.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%s -> %q for UX consistency
pkg/providers/docker/runtime.go
Outdated
func SetDockerNetwork() error { | ||
log.Trace("Initializing the Docker network provider...") | ||
plugin, err := network.GetDockerNetworkPlugin(providers.Runtime) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is unnecessary, it's always nil
pkg/providers/providers.go
Outdated
@@ -22,6 +22,10 @@ var Storage storage.Storage | |||
|
|||
type ProviderInitFunc func() error | |||
|
|||
func init() { | |||
NetworkPlugins = make(map[string]network.Plugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be an inline initialization: var NetworkPlugins = make(map[string]network.Plugin)
, no need for init()
Comments addressed, and the CI is green, merging 👍 |
Fixes: #171
Fixes: #303
This PR:
cc @twelho