Debian GNU/Linux in VirtualBox on MacOS M1 to Practice Kubernetes
Rudolf Olah

Rudolf Olah @rudolfolah

About: Eng Manager / Staff Software Eng

Location:
Canada
Joined:
Jun 9, 2019

Debian GNU/Linux in VirtualBox on MacOS M1 to Practice Kubernetes

Publish Date: May 11
0 0

When studying for the CKAD (Certified Kubernetes Application Developer) exam, I practiced using the Killer Coda CKAD scenarios and the Killer Shell Exam Simulator. The exam simulator sets up a remote Linux XFCE desktop environment with a browser and terminal.

When practicing various Kubernetes commands, I used minikube and colima to set up Kubernetes with Docker. However, this isn’t the same experience as navigating a desktop with a specific resolution, set of tools, and slightly different keyboard shortcuts. To get the same experience, without being limited to a few exam simulator sessions, I looked into VirtualBox and Vagrant. VirtualBox is a virtualization system, and Apple Silicon chips became supported by VirtualBox in September 2024.

VirtualBox 7.1

Here are the steps I took to run a Debian desktop environment in VirtualBox:

  1. Download version 7.1+ of VirtualBox for macOS / Apple Silicon hosts
  2. Download an ARM64 ISO for the Debian GNU/Linux distribution
  3. Install VirtualBox
  4. Start VirtualBox
  5. Drop the Debian .iso file onto VirtualBox
    1. You can “skip the unattended installation”
    2. Set the hard disk size, base memory, and number of processors
  6. Adjust the amount of storage in the settings for the virtual machine
  7. Go to Settings > Display for the virtual machine and change the “Scale Factor” from 100% to 200% (or larger)
  8. Go to Settings > Network and change “Attached to” from NAT to Bridged Adapter, the Adapter Type to “Intel PRO/1000 MT Desktop (82540EM),” and the Promiscuous Mode to “Allow All.” The network settings must be fixed if the network mirrors do not work correctly during the installation process.
  9. Start the virtual machine and follow the usual steps for a Debian installation

Image description

For Kubernetes, you can install kubectl and minikube via apt-get:

# kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
chmod u+x ./kubectl

# minikube
curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube_latest_arm64.deb
sudo dpkg -i minikube_latest_arm64.deb

# test the installation
minikube start
kubectl get po -A
Enter fullscreen mode Exit fullscreen mode

You may need to unset the following VirtualBox global setting because it could cause issues with spinning up a virtual machine on Apple Silicon:

VBoxManage setextradata global "VBoxInternal/Devices/pcbios/0/Config/DebugLevel"
Enter fullscreen mode Exit fullscreen mode

Vagrant

Many of the above steps are manual and can be done through the VirtualBox interface. You can use Vagrant to automate the steps. Vagrant makes it simpler to reproduce a working virtual machine environment.

Install Vagrant using Homebrew:

brew tap hashicorp/tap
brew install hashicorp/tap/hashicorp-vagrant
Enter fullscreen mode Exit fullscreen mode

For the manual steps above to change the storage and network settings, this is how you would automate the configuration with Vagrant:

config.vm.provider "virtualbox" do |vb|
  # ...
  vb.customize ["storagectl", :id, "--name", "VirtIO Controller", "--hostiocache", "on"]
  vb.customize ["modifyvm", :id, "--nictype1", "82540EM"]
end
Enter fullscreen mode Exit fullscreen mode

DNS resolution can be provisioned with this:

config.vm.provision "shell", inline: <<-SHELL
  echo 'DNS=8.8.8.8' >> /etc/systemd/resolved.conf
  systemctl restart systemd-resolved
SHELL
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment