Set Up an x86 K3s Cluster on Apple Silicon with OrbStack
Please excuse the slightly awkward title.
If you’re not interested in Apple Silicon, OrbStack, x86 architecture, or K3s clusters, this article may not be for you.
Background
In my workflow, I rely on a combination of an M1 MacBook Pro and various high-performance tools. I use OrbStackto create virtual machines. This platform, through binary translation via Rosetta for virtualization, offers not only fast virtualization speeds but also numerous other benefits (for more details, see Why OrbStack). Additionally, I prefer using K3s clusters due to their lightweight nature, coupled with the previously introduced k3sup tool, which allows for rapid cluster setup.
Although this combination of tools is primarily designed for speed and portability, they present some technical challenges when used together. For example, while installing K3s on an x86 virtual machine created with OrbStack, I encountered a common issue that has been widely discussed in the community and seems unsolvable, as detailed in this GitHub discussion.
Failed to create pod sandbox: rpc error: code = Unknown desc = failed to generate sandbox container spec options: failed to generate seccomp spec opts: seccomp is not supported
In my virtual environment, although running containers with Docker posed no issues, installing K3s presented challenges. It’s worth noting that both Docker and K3s depend on Containerd as the container runtime, which led me to suspect the issue might lie in the Containerd configuration embedded within K3s.
A potential solution is to configure K3s to use Docker as the container runtime. Fortunately, the K3s official documentation mentions that by adding the --docker
parameter during cluster creation, this configuration can be achieved, as detailed in K3s documentation.
Next, we will test this solution to see if it resolves the issue encountered while installing K3s on the x86 virtual machine.
Verification
Installing the Virtual Machine
First, install OrbStack.
brew install orbstack
Create an x86 Ubuntu 22.04 virtual machine via the command line.
orb create -a amd64 ubuntu:jammy ubuntu
Alternatively, you can use OrbStack’s GUI for the operation.
To SSH into the virtual machine, use the command ssh ubuntu@orb
.
Installing Docker
SSH into the virtual machine and install Docker.
Before starting, install gpg
.
sudo apt update
sudo apt install -y gpg
Refer to the Docker official documentation for installation or use the following commands.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt -y install docker-ce docker-ce-cli containerd.io
echo ""
newgrp docker
sudo usermod -aG docker $USER
Check if Docker is working properly. As indicated, it uses the amd64
platform image.
docker run --rm hello-world
With the container runtime ready, proceed to install k3s.
Installing the K3s Cluster
Install the latest version of k3s, disabling traefik
, local-storage
, metrics-server
, and servicelb
for an ultra-lightweight setup. Don't forget the --docker
parameter.
curl -sfL https://get.k3s.io | sh -s - --disable traefik --disable local-storage --disable metrics-server --disable servicelb --write-kubeconfig-mode 644 --write-kubeconfig ~/.kube/config --docker
You can also use the previously shared [k3sup installation script](https://gist.github.com/addozhang/92905325746b7858e3d
06117d6b9d0b8#file-setupk3s-sh) with the command: ./setupk3s.sh --docker --mini
.
--mini
option disables all optional components.
Check the cluster’s status.
kubectl version
kubectl get po -A
By examining the nodes, you can see that Docker is used as the container runtime.
kubectl get no -o wide
Finally, remember to delete the virtual machine.
orb delete ubuntu