cloud native technologies

Articles about cloud native and devops technologies.

Follow me on GitHub

As a testing environment we want to be able to provision local pre configured machines based on different OSs.

As our target solution to be tested will use virtualization the virtual machines created should allow use virtualization (this is achieved through nested virtualization).

Setup

Download vagrant from

Based on RHEL ensure KVM and libvird are properly configured:

sudo systemctl status libvirtd

KVM supports nested virtualization, in this case the provider used by vagrant to manage KVM is libvirt and it allows to configure nested virtualization with the config parameter nested as true:

config.vm.provider :libvirt do |libvirt|
  # Enable KVM nested virtualization
  libvirt.nested = true
  libvirt.cpu_mode = "host-model"
end

Issues

No usable default provider… libvirt requires plugin installation to manage the provider:

vagrant plugin install vagrant-libvirt

Due to some issue compiling the sources for the provider it is prefererd to install vagrant using dnf (this is due to the management for internal dependices, like embedded ruby)

sudo dnf install --disablerepo=* -y https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.rpm

vagrant plugin install vagrant-libvirt

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "fedora/32-cloud-base"
  config.vm.box_version = "32.20200422.0"
  
  config.vm.provider :libvirt do |libvirt|
    # Enable KVM nested virtualization
    libvirt.nested = true
    #host-model is deprecated at rhel 8 use pass-through instead
    libvirt.cpu_mode = "host-passthrough"
    # Increase memory allocation for CRC requirements
    libvirt.memory = 10238
  end  
end

Check virtualized resources

Check virtual networks (vagrant create / use its default):

sudo virsh net-list --all
sudo virsh net-dumpxml $NETWORK_NAME

Check VMs:

sudo virsh list --all

Extend vagrnat with dns

TBC

Bibliography

1. RHEL virtualization

2. Vagrant inside vagrant

3. Vagrant libvirt plugin installation

4. Vagrant issue installing libvirt plugin

5. Nested virtualization on RHEL 8