Vagrant Libvirt on WSL

To use pure Vagrant on WSL, it must not detect it’s on this setup (the check is made on platform.rb).
Either :

  • recompile the WSL kernel to remove microsoft in the name
  • recompile vagrant removing the check to be always false
def wsl?
  if !defined?(@_wsl)
    @_wsl = false
    SilenceWarnings.silence! do
      # Find 'microsoft' in /proc/version indicative of WSL
      if File.file?('/proc/version')
        osversion = File.open('/proc/version', &:gets)
        if osversion.downcase.include?("microsoft")
          @_wsl = false
        end
      end
    end
  end
  @_wsl
end

Then recompile

git clone https://github.com/hashicorp/vagrant.git
cd vagrant
rvm install ruby-2.7
rvm gemset use --create ruby-2.7@vagrant
bundle config set --local path vendor/bundle
bundle install
bundle binstubs --path exec --all
vagrant plugin install vagrant-libvirt

Vagrant-libvirt use nfs for bidirectionnal folder access between host and guest (as virtualbox folder is not available)

These options must be run :

sudo /etc/init.d/rpcbind restart
sudo /etc/init.d/nfs-kernel-server restart

Change the vagrant-libvirt management network to another CIDR than 192.168.121.0/24 (for ex 192.169.121.0/24) as it will collide with the 192.168.0.0/16 of Calico.

virsh net-edit vagrant-libvirt
virsh net-destroy vagrant-libvirt
virsh net-start vagrant-libvirt

Use this repo : https://github.com/oxenit/vagrant-kubeadm-kubernetes