Let Weave Net Allocate IP Addresses for You
One of the chores when using Weave Net is giving each container an IP address. We recognized this, and we’ve automated it for you, as a new feature in Weave release 0.11. Take a look at the walk-through in the documentation....
One of the chores when using Weave Net is giving each container an IP address. We recognized this, and we’ve automated it for you, as a new feature in Weave release 0.11. Take a look at the walk-through in the documentation.
We’ve designed this feature to be fast, resilient, and simple to deploy and use. Let’s look at how that is achieved…
For the first item, fast, we let each host on the Weave network own some IP addresses, and hand them out locally to containers that need them. If one host runs out of IP addresses, it asks another to hand some over. Simple as that.
To be resilient, we have no master node; no single point of failure. In fact, every node on the system will cooperate with any other nodes it can talk to, and if you partition the network (e.g. the link between two data-centres goes down) then each part will continue to operate independently. This is achieved using a Convergent Replicated Data Type or CRDT which we periodically transmit to neighbours. If some nodes restart, they will pick up their state from peers and carry on as before. We don’t persist the state, so if every node restarts at the same time they’ll need to start from scratch.
It’s simple to deploy because the only things you need to specify are (a) which IP subnet you want your containers to use and (b) how many nodes will be in your network. Generally the subnet will be part of a private IP range such as “10.2.0.0/16”. It’s the one thing you have to pick, because we don’t know what else you need to interoperate with – for example, if your enterprise already has key services in the 10.2 network you wouldn’t want Weave to choose the same address as one of those, so you might tell Weave to use 192.168.8.0/22. And weave needs to know how many nodes are in your network because it wants a majority of nodes to agree that it should create a completely blank data structure at start-up.
(By the way, those strings of numbers are CIDR notation – the first part is the starting address and the number after the / is the length of the network prefix – /22 means 22 out of 32 bits specify the network so you have 10 bits left to make 1024 individual addresses. Well, 1022 actually, since the first and last ones are reserved)
And it’s simple to use because you just do “weave run” instead of “docker run” and Weave will pick an IP address for you then wire up the network.
We could have made the implementation a lot simpler by just asking you, the user, to set a different range of IP addresses on each host. But statically carving up the address space limits the flexibility – if you’ve shared out all the space you need to re-configure some hosts when you want to add new ones, and if the numbers of containers running on each host turn out to be highly skewed, you will run out of addresses on one host while still having plenty available on another.
So, weave’s IP address management is fully dynamic – it will re-allocate IP addresses to where they are needed, if they are not in use elsewhere.