Switching from Minikube with VirtualBox to KVM

What I learned today — 11 June 2018

Niel de Wet
1 min readJun 11, 2018

Minikube is an indispensable tool for developing on Kubernetes. By default it uses VirtualBox for virtualisation, and that works fine, although the resource usage started to bother me. When running about a dozen Java microservices and a PostgreSQL server to back each of those, my laptop would be chomping far more than its 16Gb of physical memory and go well into swap space. Once I switched to KVM (Virtualisation tool on Linux) the machine hardly notices the workload. Using virt-manager I can see that the guest VM now consumes less than 5Gb, after enabling memory sampling (Edit -> Preferences -> Polling -> Poll Memory Stats). This is a plainly noticeable improvement over using VirtualBox.

Steps to switch:

  1. Run minikube delete
  2. Also remove ${HOME}/.minikube
  3. Install the appropriate libvirt and qemu dependencies. See official docs.
  4. Start minikube with the KVM2 driver, and your favourite other options: minikube start --vm-driver kvm2
  5. Everything else works the same as before

Restarting minikube

After stopping minikube you may run into an issue when trying to restart it.

Error starting host: Error starting stopped host: Error creating VM: virError(Code=55, Domain=19, Message='Requested operation is not valid: network 'minikube-net' is not active').

KVM will not autostart the minikube network. To instruct KVM to autostart it, run:

virsh net-autostart minikube-net

Start the stopped network:

virsh net-start minikube-net

You can see a list of networks with their status by running:

virsh net-list --all

--

--

Responses (1)