Kubernetes: Minikube with QEMU/KVM on Arch
Tags: kubernetes, docker, archlinux, virtualization
Published: 2020-08-24 23:28:32

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6glk0y4gowgeg9gpp3cn.jpg)

[Minikube](https://minikube.sigs.k8s.io/docs/) 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
```

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
```
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
```

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
```

Change the Minikube driver to kvm2:
```
🐺 ~ ⚡ ➜ minikube config set driver kvm2
```

It's nice to create a seperate kubeconfig file for `Minikube` to use for the cluster:
```
🐺 ~ ⚡ ➜ touch config && export KUBECONFIG=$(pwd)/config
```

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"
```

Your `kubectl` should now be talking to the minikube cluster! If you run into any issues, you can check [Minikube Docs](https://minikube.sigs.k8s.io/docs/) and [ArchWiki](https://wiki.archlinux.org/index.php/Main_page).