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
Configurable grid subnet, supernet #1323
Conversation
d6019b3
to
26cbf4a
Compare
Rebased for 0.17 git master |
26cbf4a
to
91cec77
Compare
Rebased for 1.0 git master. TODO on fixing up the
We can't attach containers until we have the grid configuration, which changes the WeaveWorker` startup ordering again. |
Assigning to me as I still need to work on the configurable subnet migration. |
Is this progressing? |
This is blocked on the hardcoded |
But this can be only configured when grid is created, right? I can't see how this affects <1.0 migration? |
The WeaveWorker needs to know if the For new service containers being deployed, it's indeed not an issue; the server assigns them an |
91cec77
to
c7f9a27
Compare
Rebased to current git master. Travis is failing on the flaky server specs. |
The CLI/server parts of this are pretty straightforward, but the agent bits are pending on a major refactoring to clean up the |
8ab7b54
to
7078b06
Compare
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.
Some minor comments on code, overall looks good.
Documentation should be updated, especially regarding the supernet/subnet relation. That might not be really intuitive for all the Kontena users.
Some quick testing locally:
$ k grid create --supernet 10.90.0.0/12 --subnet 10.90.0.0/17 subnet-test
# ip addr show dev weave
33: weave: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1410 qdisc noqueue state UP qlen 1000
link/ether de:58:13:a5:1e:ce brd ff:ff:ff:ff:ff:ff
inet 10.90.0.1/17 scope global weave
valid_lft forever preferred_lft forever
inet6 fe80::dc58:13ff:fea5:1ece/64 scope link
valid_lft forever preferred_lft forever
$ k service create web nginx && k service deploy web
$ k service show web | grep ip:
ip: 10.90.64.65
Everything works as expected.
# override label for existing containers that may need to be migrated | ||
if container.overlay_network.nil? | ||
# overlay network migration for 0.16 compat | ||
# override overlay network /12 -> /16 suffix for existing containers that may need to be migrated |
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.
/12 network? Do you mean the old (< 1.0) /19 subnet?
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.
Fixed. I thought I rgrep'd for all of these; I confused the grid supernet with the old subnet :)
'grid' => { | ||
'initial_size' => 3 | ||
'initial_size' => 3, | ||
'subnet' => '10.81.0.0/16', |
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.
node_info
is repeating quite often in the test cases, maybe do a let(:node_info)...
over it?
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.
Refactored specs to use context node_info
@@ -0,0 +1,48 @@ | |||
class IPAddr |
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're doing IPAddr patching in many places now, maybe it's time to roll these as a separate gem? (not maybe part of this PR, but overall)
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.
Yes, the stdlib IPAddr
is really inadequate. I figure these should be replaced with the ipaddress
gem.
The worst part is the crazy-looking IPAddr
operations on the server, like
(IPAddr.new(self.grid.subnet) | self.node_number).to_s
This would be make somewhat more sense with the agent IPAddr patching (IPAddr.new(self.grid.subnet)[self.node_number]
), but the way the kontena repo is structured, there's no easy way to share code between across all three sub-components...
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.
Should I fix all the server and agent stuff to start using ipaddress
in this PR, or later?
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.
I think we should do it later as separate exercise.
The plugins will also need to fixed to use the |
Added Kontena Network Model docs. Not sure what other docs should mention this? It's a pretty niche thing... until we have to start dealing with platforms/providers using |
@kke IMO this should be mostly okay for 1.1, if we want to. Need to fix the plugins to support this after merging, though. |
docs/core-concepts/networking.md
Outdated
Both of these private RFC1918 IP address spaces are used for internal overlay networking within each grid. | ||
These overlay network addresses are only unique within a grid; different grids can (and will) use the same overlay network IP addresses. | ||
|
||
The grid subnet (`10.81.0.0/16`) is used to provide overlay networking addresses for both host nodes and service contaienrs. |
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.
Small typo
I think the grid command reference should be updated to reflect this in |
Fixed several other things at the same time, see #1727 |
* docs grids: document grid options, initial nodes * edit, fix links * remove references to #1323
… a io.kontena.container.overlay_network label
95df01b
to
0195cde
Compare
Rebased for latest 1.1.x master, pruned the /16 validation stuff, and re-added the grid subnet docs left out of #1727 |
Fixes #1304
Server
Add
Grid
subnet
,supernet
to model, JSON viewsAdd
HostNode
overlay_ip
to models, JSON viewsUses
IPAddr
to compute the offset, allowing the use ofnode_number > 255
once any existing10.81.1.X
service containers are migrated over to the new10.81.128.X
range.Support optional
POST /grids {"subnet": "...", "supernet": "..."}
Migrate existing girds to use the current default subnet/supernet
CLI
kontena grid cloud-config
--insecure-registry=
from the grid subnetkontena grid create --subnet= --supernet=
Agent
Add
IPAddr
helpersUse
node_info['grid']['subnet']
andnode_info['overlay_ip']
for etcd, weave launchersUse
node_info['grid']['supernet']
for the IPAM launcherUse
node_info['grid]['subnet']
for the default kontena networkAutomatically compute the iprange from the upper half of the grid subnet.