Skip to content

0021 - Gitea Actions Runners in a Lima k3s VM on the Mac Mini, amd64 Builds Through Rosetta

Status

Proposed 2026-10-22 in Taskbase task #1458 (milestone "Gitea Actions runners on the Mac mini", epic #68). It follows the owner's decision of 2026-10-22 that all Gitea Actions runners leave hetzner-mgmt to free its resources. ADR 0020 §3 already decided the frame: the runners get their own Lima instance ci under their own macOS account, with at most 4 cores and 6 GiB, and not a namespace in the operator's VM ops. This record decides what runs inside that VM, how amd64 images are built on an arm64 Mac, and how big the VM is.

The record is accepted when its pull request is merged. It changes nothing live: the owner's install (#1466) starts the VM, and #1459 removes the cluster runners after the cutover.

Amended 2026-10-23 by ADR 0022 (task #1487). The runners do not get their own VM and account: they run rootless in the namespace ci of the one Lima VM k3s, next to the operator, from cluster/mac-mini/ (the rows marked below). What this record measured and chose still holds: k3s with Flux and the component plus an overlay, Rosetta with Ubuntu 24.04, the /tmp tmpfs, the labels, four jobs at once, the token Secret and no Harbor credentials. The install is Gitea Actions Runners on the Mac Mini.

Date

2026-10-22

Context

Today components/gitea/act-runner/ runs two pods on hetzner-mgmt. Each pod has a Docker daemon (dind) and two act_runner processes of capacity: 1, so four jobs run at once (CI Runners). The workers are amd64 (cx33); the Mac mini is an Apple M4 (4 performance and 6 efficiency cores), 16 GiB, macOS 15.5, arm64.

What the workflows need is listed in the inventory. In short:

  • Every job needs Docker: act runs each job in a container, three repositories start a postgres service, and 17 jobs in 11 repositories build images inside the job container harbor.prod.skatzi.com/library/kaniko-runner:latest.
  • kaniko-runner:latest is amd64 only, and every image build passes --custom-platform linux/amd64, because the images run on hetzner-mgmt. So each image build runs amd64 code: kaniko itself, and each RUN step of the Dockerfile.
  • Six workflows download amd64 binaries (helm, kustomize, kubeconform, promtool, staticcheck, yq) and run them.
  • No workflow reaches anything cluster-internal, except the reusable _terraform-* workflows in platform, which nothing calls.
  • Of the runners' cluster secrets, only the registration token is needed.

Facts checked for this record

Fact Source
act_runner v0.6.1 never sets act's ContainerArchitecture, so job containers use the daemon's native platform (arm64 here). An amd64-only image such as kaniko-runner is pulled as amd64 and runs through binfmt. internal/app/run/runner.go (the act config has no ContainerArchitecture); act/container/docker_run.go (Platform is passed only when set)
container.options of the runner config reach every job container, merged with the workflow's own container.options. Service containers get only the workflow's options. --tmpfs survives; binds and mounts are dropped when valid_volumes is empty, anonymous volumes too. act/runner/run_context.go (options(), and Options: spec.Options for services); act/container/docker_run.go (mergeContainerConfigs, sanitizeConfig)
Image platforms: docker.gitea.com/runner-images:ubuntu-latest/24.04/22.04 amd64 and arm64; gitea/act_runner:0.6.1, docker:29.9.1-dind, postgres:16/18 include arm64; kaniko-runner:latest is amd64 only (pushed 2026-03-07). The registries' manifest lists; the Harbor API (/api/v2.0/projects/library/repositories/kaniko-runner/artifacts), 2026-10-22
Rosetta aborts an amd64 process when the container has no /tmp: assertion failed [!result.is_error]: Failed to create temporary file (ThreadContextFcntl.cpp:85 create_tempfile), exit 133. kaniko-runner has no /tmp. TMPDIR does not help; a tmpfs at /tmp does. Kaniko leaves the mount out of what it builds, and the built docs image still has its base image's /tmp. docker run --platform linux/amd64 of the kaniko executor on the Mac mini, with and without --tmpfs /tmp, 2026-10-22
Rosetta (macOS 15.5) does not run on Linux 7.0. In an Ubuntu 26.04 guest (kernel 7.0.0, Lima 2.2.1's ubuntu-lts), every amd64 process stops with rosetta error: unhandled auxillary vector type 29. Ubuntu 24.04 (kernel 6.8) works. A Lima instance from each image on the Mac mini, 2026-10-22
Jobs that dind starts run outside its pod's cgroup. Docker inside the privileged dind container sees the VM's cgroup root and puts its containers under /sys/fs/cgroup/docker. Two Keycloak builds peaked at 3,864 MiB there, while the pod's cgroup peaked at 253 MiB with no limit hit. A memory limit on dind does not cap jobs; the VM does. memory.peak of both cgroups in the k3s test VM, 2026-10-22
A VZ VM keeps the host memory it has touched. After the builds, the Virtualization.VirtualMachine process of a 6 GiB VM had 7.2 GiB resident on the Mac. ps on the Mac mini, 2026-10-22
A VZ VM with Rosetta starts from a launchd job outside the GUI session (the user/501 domain, LimitLoadToSessionType Background), so starting at boot without a login does not depend on a GUI. ADR 0020 records that limactl autostart --condition=boot installs a LaunchDaemon for that. launchctl bootstrap user/501 of a test job that ran colima start with --vz-rosetta, 2026-10-22; ADR 0020, facts
Lima forwards every guest TCP port bound on 127.0.0.1 to the Mac's 127.0.0.1 unless a rule ignores it. An ignore rule for 0.0.0.0 alone still forwarded k3s's 6444, 10248, 10257 and 10259, which ops binds too. limactl start log of the test instance, before and after adding the 127.0.0.1 rule, 2026-10-22
limactl autostart enable --condition=boot must be run by the instance's owner: it reads the instance from the caller's LIMA_HOME, then runs sudo launchctl bootstrap system …. limactl refuses to run as root. So for a standard account (ci-runner, agent-ops) an admin installs the same plist by hand. In v2.2.1, the Homebrew version, that plist sets no LIMA_HOME and no KeepAlive; Lima's main adds both. Lima v2.2.1 cmd/limactl/autostart_darwin.go (daemonInstall, runSudo), cmd/limactl/main.go, pkg/autostart/launchd/io.lima-vm.daemon.INSTANCE.plist at v2.2.1 and main
Rosetta was not installed on the Mac mini. softwareupdate --install-rosetta --agree-to-license installed it without sudo. The Mac mini, 2026-10-22
Gitea 1.25.5's /metrics has no Actions or runner metrics. act_runner v0.6.1 has a metrics endpoint, off by default and listening on localhost. Gitea modules/metrics/collector.go at v1.25.5; act_runner internal/pkg/config/config.example.yaml (metrics)

Measured builds

The platform docs image (docs/Dockerfile) and the Keycloak image (components/keycloak/Dockerfile) were built with the real kaniko-runner:latest image and --custom-platform linux/amd64 --no-push on the Mac mini, in a VM with 4 vCPUs. The Mac mini times do not include the context download or the push to Harbor; the hetzner-mgmt time is the whole build job.

Build hetzner-mgmt today QEMU (Lima vz, binfmt) Rosetta (Lima vz) Rosetta in the chosen stack (k3s, dind pod)
Docs median 64 s, p90 81 s (162 runs, 2026-10-08 to 10-21) 72 s, 74 s 36 s (3 of 3) 31 s (2 of 2)
Keycloak no run in the last 1,500 platform jobs 67 s, 70 s, 74 s, 116 s; hung 2 of 6 times in kc.sh build (stopped after 5 and 9 min) 66–74 s (7 of 7) 62–63 s (3 of 3; two at once both passed)

Where the time goes: in the Keycloak build, about 35 s is pulling the base image on either emulator, and kc.sh build (Java) takes 26 s with Rosetta and 32 s with QEMU when it finishes. In the docs build, pip install takes 9 s against 19 s, and zensical build 5 s against 26 s.

Options considered

What runs inside the ci VM

  • A. k3s, Flux, and the existing components/gitea/act-runner with an overlay (chosen). It is the same Deployment as on hetzner-mgmt: dind with two runner processes per pod, graceful drain, and the cache fixes. Flux applies cluster/mac-mini-ci ADR 0022: cluster/mac-mini/ci/ from Git, and Renovate keeps the versions current. Idle k3s used 0.9 GiB of the test VM; Flux adds its two three (ADR 0022) controllers.
  • B. A Docker engine in the VM, with act_runner as Docker Compose services. It saves the k3s memory. But its configuration lives outside GitOps. With no host mounts, every change must be copied into the VM and applied by hand. The drain on update and the four-process layout would be rebuilt in Compose.
  • C. act_runner on macOS, with DOCKER_HOST pointing at the VM's engine. Four more host services, under launchd instead of Kubernetes, and the runner processes outside the VM's limits.

amd64 code on an arm64 Mac

  • Rosetta (chosen). It needs vmType: vz and an Ubuntu 24.04 guest (see the facts). It was faster in every step, and it never hung.
  • QEMU user-mode emulation through binfmt. Slower, and the Keycloak build hung in 2 of 6 runs, which in CI is a stuck job until the 3-hour timeout.
  • Build natively for arm64. Not possible: the images run on amd64 hetzner-mgmt, so their RUN steps must run amd64 code whatever builds them.

A /tmp for amd64 job containers

  • A tmpfs at /tmp in every job container, from the runner config (chosen). One line in this repository; no workflow changes. With the tool cache moved to /opt/toolcache, it holds only temp files, capped at 1 GiB.
  • Add /tmp to kaniko-runner. Its source is in none of the repositories checked. The image was pushed in March 2026 with buildah. It would also have to stay amd64-only or gain an arm64 variant.
  • options: --tmpfs /tmp in each image-build job. 17 jobs in 11 repositories, and every new workflow must remember it.

Decision

Chosen: option A in a Lima VM ci k3s (ADR 0022) with Rosetta, configured in cluster/mac-mini-ci/ ADR 0022: cluster/mac-mini/ci/:

Setting Value Why
macOS account ci-runner, standard, owns ~ci-runner/.lima ADR 0022: none of its own; the VM belongs to agent-ops ADR 0020 §3: no CI code in the accounts of mac-mini, agent-release-build or agent-ops. Superseded: CI code runs unprivileged inside the VM, not as a macOS account
VM Lima instance ci from cluster/mac-mini-ci/lima/ci.yaml ADR 0022: the shared instance k3s from cluster/mac-mini/lima/k3s.yaml, 6 vCPUs, 9 GiB, 50 GiB: vmType: vz, Rosetta with binfmt, Ubuntu 24.04, no host mounts, no port forwards Rosetta needs vz and a kernel it supports (6.8 works, 7.0 does not). Rootless dind starts jobs in its own container's cgroup, so its memory limit, not the VM, caps CI (to be measured at install)
Boot io.lima-vm.daemon.ci ADR 0022: io.lima-vm.daemon.k3s (limactl start k3s --foreground as agent-ops), installed from cluster/mac-mini/host/ limactl autostart cannot install it for a standard account (see the facts)
Kubernetes k3s pinned in the template (param.k3sVersion, Renovate), --secrets-encryption, traefik, servicelb and metrics-server off As ops
GitOps Flux source-controller, kustomize-controller and helm-controller (ADR 0022, for the ops-agent HelmRelease); GitRepository platform over SSH with a read-only deploy key; root path ./cluster/mac-mini-ci ADR 0022: ./cluster/mac-mini, which lists ci/ No configuration by hand in the VM
Runners Namespace act-runner ci (ADR 0022): the component's Deployment, two pods of two processes (four jobs at once, as today; ADR 0022 Q5: a pod per queued job, at most two at once), registered as mac-mini-<pod> and mac-mini-<pod>-2. ADR 0022: rootless dind (hostUsers: false, the tun device plugin, NetworkPolicies) instead of privileged dind Same capacity ADR 0022 Q5: half the capacity, two jobs at once instead of four (memory: 2 × 3 GiB in the 9 GiB VM); the names show where a job ran
Labels ubuntu-latest, ubuntu-24.04, ubuntu-22.04 → docker.gitea.com/runner-images:*, as today The same images, now as arm64
amd64 Rosetta through binfmt, for kaniko-runner and downloaded amd64 tools; --tmpfs /tmp:exec,size=1g on job containers See the facts and measurements
Token Secret gitea-act-runner-token (key token) in act-runner ci, created once by the owner with kubectl create secret from a hidden prompt Replaces the ExternalSecret from OpenBao; never in Git or a task
Harbor credentials none Every job image is public. harbor-pull-secret becomes optional in the overlay

Size. (Amended by ADR 0022: the runners share a 9 GiB VM with the operator, and each dind is limited to 3 GiB; the reasoning below about the VM as the cap applied to privileged dind.) Four jobs used about 1.8 GiB on hetzner-mgmt (two pods, each at most 936 MiB over 7 days), and two Keycloak builds at once peaked at 3.8 GiB including page cache. Idle k3s takes 0.9 GiB, so 5 GiB holds four ordinary jobs, or two image builds next to two light jobs. 6 GiB, ADR 0020's ceiling, would cost about 7.2 GiB on the Mac, next to ops (4 GiB) and the mac-mini runner, so the VM starts at 5 GiB. If jobs are OOM-killed in the VM (dmesg), raise it to 6 GiB. If the Mac's memory pressure stays high, drop replicas to 1 (two jobs) instead. CPU: four of ten cores; jobs above that wait in the VM rather than slowing the Mac.

Consequences

Positive

  • hetzner-mgmt frees about 1.6 CPU and 2.2 GiB of requests, and up to two 5 GiB dind limits, after #1459.
  • Image builds should be faster: the docs build's kaniko step took 31 s, against a 64 s job on hetzner-mgmt that also downloads the context and pushes. The cutover measures the whole job.
  • The runners keep their tested layout and fixes: one job per process, per-job tool cache, graceful drain, fetch_timeout. Flux applies them from Git and Renovate updates their images, as on hetzner-mgmt; Flux itself in the VM is not tracked by Renovate and is upgraded by hand.
  • (ADR 0022: now through rootless pods and NetworkPolicies in the shared VM, not a separate account and VM.) CI cannot reach the operator's break-glass kubeconfig, or the Mac's files: separate account, no mounts, no forwarded ports.

Negative

  • CI depends on one Mac at home: its power, its uplink to Harbor and Gitea, and macOS updates. An image push now goes over the home upload link. The cutover measures it.
  • Rosetta becomes a dependency, an Apple component we do not control. The guest cannot follow Ubuntu's next LTS kernel until Rosetta runs on it. If Rosetta goes, the fallback is QEMU (slower, with the hangs above), or building images on a runner in hetzner-mgmt again.
  • The CI health signals of hetzner-mgmt go away: the gitea pods in "Pods not ready" and "Pods crash-looping" on Platform health, and the runners' CPU and memory. What replaces them is in Logs and metrics; #1467 puts them on Platform health.
  • The Mac mini's disk: the VM disk can grow to 30 GiB (50 GiB for the shared VM, ADR 0022), and freed space inside the VM may not return to the Mac. ADR 0020 §3 already requires 40 GiB free after both VMs.
  • runner-config.yaml exists twice until #1459 removes the cluster runners: the component's, and the Mac mini's copy with three changed values.