DEV Community

Ismayil Mirzali
Ismayil Mirzali

Posted on

Kubernetes: Minikube with QEMU/KVM on Arch

Alt Text

Minikube is a tool for easily creating Kubernetes clusters locally.

It boasts features like supporting multiple container runtimes and even Load Balancers so you can easily test your deployments/services locally.

Minikube lets you deploy your node as a VM, container or even bare metal. The default driver is VirtualBox, however KVM/QEMU usually performs better on Linux machines.

I assume that you'll be using Docker as your CRI. On Arch Linux, you'll need to get the following packages using Pacman:

๐Ÿบ ~ โšก โžœ sudo pacman -S minikube libvirt qemu dnsmasq ebtables dmidecode
Enter fullscreen mode Exit fullscreen mode

You then need to add your user to the libvirt group and start the service:

๐Ÿบ ~ โšก โžœ sudo usermod -aG libvirt $(whoami)
๐Ÿบ ~ โšก โžœ sudo systemctl start libvirtd.service
๐Ÿบ ~ โšก โžœ sudo systemctl enable libvirtd.service
Enter fullscreen mode Exit fullscreen mode

The libvirtd service may fail due to certain missing binaries, be sure to check the status and resolve any issues you may have.

๐Ÿบ ~ โšก โžœ sudo systemctl status libvirtd.service
Enter fullscreen mode Exit fullscreen mode

You can then run the validation tool:

๐Ÿบ ~ โšก โžœ virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for device assignment IOMMU support                         : PASS
  QEMU: Checking if IOMMU is enabled by kernel                               : PASS
  QEMU: Checking for secure guest support                                    : WARN (AMD Secure Encrypted Virtualization appears to be disabled in kernel. Add kvm_amd.sev=1 to the kernel cmdline arguments)
  LXC: Checking for Linux >= 2.6.26                                          : PASS
  LXC: Checking for namespace ipc                                            : PASS
  LXC: Checking for namespace mnt                                            : PASS
  LXC: Checking for namespace pid                                            : PASS
  LXC: Checking for namespace uts                                            : PASS
  LXC: Checking for namespace net                                            : PASS
  LXC: Checking for namespace user                                           : PASS
  LXC: Checking for cgroup 'cpu' controller  support                         : PASS
  LXC: Checking for cgroup 'cpuacct'  controller support                     : PASS
  LXC: Checking for cgroup 'cpuset'  controller support                      : PASS
  LXC: Checking for cgroup 'memory'  controller support                      : PASS
  LXC: Checking for cgroup 'devices'  controller support                     : PASS
  LXC: Checking for cgroup 'freezer'  controller support                     : PASS
  LXC: Checking for cgroup 'blkio'  controller support                       : PASS
  LXC: Checking if device  /sys/fs/fuse/connections exists                   : PASS
Enter fullscreen mode Exit fullscreen mode

Change the Minikube driver to kvm2:

๐Ÿบ ~ โšก โžœ minikube config set driver kvm2
Enter fullscreen mode Exit fullscreen mode

It's nice to create a seperate kubeconfig file for Minikube to use for the cluster:

๐Ÿบ ~ โšก โžœ touch config && export KUBECONFIG=$(pwd)/config
Enter fullscreen mode Exit fullscreen mode

Finally, run minikube:

๐Ÿบ ~/repos โžœ minikube start
๐Ÿ˜„  minikube v1.12.2 on Arch
    โ–ช KUBECONFIG=/home/lemagicien/repos/config
โœจ  Using the kvm2 driver based on user configuration
๐Ÿ‘  Starting control plane node minikube in cluster minikube
๐Ÿ”ฅ  Creating kvm2 VM (CPUs=2, Memory=4000MB, Disk=20000MB) ...
๐Ÿณ  Preparing Kubernetes v1.18.3 on Docker 19.03.12 ...
๐Ÿ”Ž  Verifying Kubernetes components...
๐ŸŒŸ  Enabled addons: default-storageclass, storage-provisioner
๐Ÿ„  Done! kubectl is now configured to use "minikube"
Enter fullscreen mode Exit fullscreen mode

Your kubectl should now be talking to the minikube cluster! If you run into any issues, you can check Minikube Docs and ArchWiki.

Top comments (0)