Skip to content
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

Support for VirtualBox network resources #2

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

onixie
Copy link

@onixie onixie commented Feb 28, 2020

Motivation to the change

As I proposed in NixOS/nixops#1223, this PR focuses on enabling VirtualBox backend to create virtual networks (Host-only and NatNetwork which VirtualBox supports) and manage those networks as NixOps resources.
It also generalizes the network adaptor configurations for the machines, removes the hard-coded constraints which pressumes the existence of a DHCP-enabled vboxnet0 link device in user's environment. After this PR, similar like libvirt backend, user can explicitly specify what networks each adaptor should be attached to.
Finally, when using with Virtualbox >= v6.1, the new virtual network resources allow user specify static IPv4 address from DHCP range and bind to a specific machine. And this can finally solve the unpredictable address issue.

Test results

I tested the changes on the following environments,

OS: Ubuntu 18.04, MacOS High Sierra
NixOps: master branch
Nixpkgs: unstable channel
VirtualBox: v5.2, v6.0 and v6.1
Virtualbox image: nixops-19.09

And tried the following frequently used commands: create, deploy, redeploy, start, stop, destroy, check, info without problems. Though there are some corner cases I wasn't able to cover, I think it's already stable enough to be shared and used with NixOps developers and decent users.

So hope this PR can be approved and merged. Thank you for any comments.

Regards

VBoxManage sometimes hangs while executing network related sub-
commands in parallel.
A reboot(stop and start) is required to propogate the changes to vm.
Also modifyvm should be invoked after machine is fully stopped.
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pr-to-support-network-resources-for-virtualbox-backend-in-nixops/6066/1

@chrisportela
Copy link

I tried merging this and got it mostly working, but I'm getting some strange error where Nix doesn't like the format of the deployment.virtualbox.networks option.

@onixie
Copy link
Author

onixie commented Mar 8, 2021

@chrisportela

Thanks for verifying my PR.

The code should have no issue to run with nixops 1.8.
I actually use it in one of my personal project for network provisioning for a HA K8S cluster running on VirtualBox or Libvirt.

https://github.com/onixie/nikops/blob/master/shell.nix#L14
https://github.com/onixie/nikops/blob/master/src/cluster.nix#L44
https://github.com/onixie/nikops/blob/master/src/cluster.nix#L61-L63

Beside the above usage, I also did some tests with other combination of the options.

Due to my lack of time recently, I couldn't manage to update it with the latest version of nix and nixops.

KjMaas added a commit to KjMaas/nixops-vbox that referenced this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants