WIP: refactor create command and add macos qemu support #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor cluster create logic
Previously a large chunk of the cluster create logic took place in the long
create()
function in which it was hard to tell which parts are applicable to qemu, docker or both. Adding a third provider (macos qemu) would have complicated matters even more so I decided to refactor the logic in the aim of clearer separation of concerns and better maintainability.CreateDockerCluster
andCreateQemuCluster
create qemu
andcreate docker
sub commands commands, which show only the applicable flagsAdd macos qemu provider
qemu works macos with the only big difference being the networking setup. Current (linux) qemu logic uses CNI plugins to set up the network but that will not work on macos.
The best solution I've found thus far for configuring the network on macos is to use apple vmnet which is also supported in qemu. AFAIK vmnet or any other networking solution for macos don't support nearly the same level of configuration as linux networking tooling. I've outlined the differences in networking capabilities in the relevant request types (common, linux, macos) As you can see most of the network parameters would not be supported on macos, but it will still suffice for testing and development needs which don't require complex networking. The resulting stack would look something like this:

source and more info: https://gist.github.com/max-i-mil/f44e8e6f2416d88055fc2d0f36c6173b
The biggest problem with this approach is that there doesn't seem to be a way to assign IPs to the vms. IPs seem to be assigned semi randomly by apple DHCP somewhere within the requested CIDR. Current qemu logic assumes IPs to be known from the very beginning, meaning that a significant part of the logic has to be adapted to the scenario where IPs are known only after the VMs have started.