Set up a macOS VM build infrastructure with Orka
Set up a Harness macOS build farm that uses a MacStadium Orka cluster.
This topic describes how to run a macOS build farm on a MacStadium Orka cluster. In this configuration, you run a Harness Delegate and the VM runner on a host that has network connectivity to your Orka cluster. Working through the Orka API, the runner creates macOS VMs dynamically in response to CI build requests, runs the build on them, and then deletes them.
The following describes how Harness CI and Orka work together:
The Harness Delegate communicates directly with your Harness instance.
The VM runner provisions macOS VMs on your Orka cluster and runs builds on them.
When the delegate receives a build request, it forwards the request to the runner. The runner deploys a VM on Orka, waits for it to report an IP, runs the build on the VM, and deletes the VM when the build finishes.
The delegate and runner do not have to run on a Linux host or inside your Orka cluster. You can run them anywhere that can reach your Orka API and nodes. Go to Where to run the delegate and runner to pick a layout.
This is one of several build infrastructure options. For example, you can also run Mac builds on Harness Cloud build infrastructure.
Requirements
This configuration requires:
A MacStadium Orka cluster with:
Apple-silicon (
arm64) nodes. The Harness Orka integration deploys VMs from OCI-based images, which is Apple-silicon only.An Orka service account token with permission to deploy and delete VMs in the target namespace. Create one with
orka3 sa token(valid for 1 year by default, or use--no-expiration). If the service account lives in another namespace, add a role binding in the VM namespace. Do not use a user login token; it is short-lived, and the runner fails once it expires.
A host with Docker installed and network connectivity to your Orka API URL and to your Orka nodes. Go to Where to run the delegate and runner to pick a layout.
An Orka base image prepared for CI builds. Go to Prepare your Orka base image to build one.
Familiarity with Orka and the macOS ecosystem.
Familiarity with the Harness Platform and CI pipeline creation.
Familiarity with Harness Delegates, VM runners, and pools.
Where to run the delegate and runner
The runner communicates with Orka, so the host that runs the delegate and runner must be able to reach:
Your Orka API URL, to deploy and delete VMs.
Your Orka nodes, on TCP ports 9079–9080. With Orka's default NAT networking, a VM reports its node's IP address, and the node forwards host ports
9079/9080to lite-engine (port9079) inside the guest. So the runner host must be able to reach every Orka node on TCP9079–9080, not just the Orka API URL.
You can run the delegate and runner wherever both are true. Common options:
Colocated VM. Run the delegate and runner together on a single VM inside your Orka private network.
Kubernetes. Run the delegate and runner as separate workloads in a cluster that is bridged into your Orka network. Go to High Availability for a related pattern.
Site-to-site VPN (preferred for more than a few nodes). Connect the runner host's network to the Orka network with a VPN. This gives the runner private access to the API and all nodes without exposing them publicly.
Public IPs. You can expose Orka publicly, but every Orka node needs its own public IP (not just the Orka API URL), and egress allowlisting must cover all of them. This is workable for a few nodes but does not scale; prefer a VPN for larger clusters.
Prepare your Orka base image
The runner provisions each VM from a base image that you build once and push to an OCI registry. The runner bootstraps each VM with a small launchd daemon in the base image that, on boot, fetches the startup script the runner passes through Orka VM metadata and runs it. The startup script then downloads and starts lite-engine, which runs the build. Without this daemon, lite-engine never starts and builds never begin.
Prepare the base image as follows, then push it (see the final steps in this section) and reference it as the image in pool.yml.
Create the bootstrap script
/usr/local/bin/orka-bootstrap.sh. It fetches the startup script from the Orka VM metadata endpoint, extracts the value, base64-decodes it, and runs it. It usesplutilto parse the metadata JSON, which is built into macOS and needs no extra tools:Set its owner and permissions:
Create the
launchddaemon/Library/LaunchDaemons/com.harness.orka-bootstrap.plist. TheEnvironmentVariablesdictionary is required:launchdjobs start with a minimalPATHthat excludes/opt/homebrew/bin, and with no$HOME, both of which break the startup script.Set its owner and permissions:
Validate the daemon:
Copying the plist into place is enough; it loads automatically on the next boot. Do not run
launchctl bootstrapon the template VM: that starts the script immediately, and it fails after about a minute because there is no VM metadata to fetch yet.Install the tools your pipelines use so they are on the
PATH(for example, Git and any language toolchains). The runner's startup script placeslite-engineand its helper binaries under/opt/homebrew/binand/usr/local/bin, so make sure those directories exist.Clear the bootstrap logs so the saved image starts clean:
Push the image to an OCI registry with vmPush (for example, GitHub Packages or Harbor). You reference the pushed image as
imageinpool.yml. (Orka also has an olderimageSavethat stores NFS-backed, cluster-local images, but that path is deprecated in Orka 4.0, so use an OCI registry.)First, register the registry credentials once per namespace. This is not needed for MacStadium's public base images (
ghcr.io/macstadium/orka-images/...):The registry must present a TLS certificate that the Orka nodes trust. On MacStadium-hosted clusters, that means a publicly trusted certificate.
Then push the image:
(Strongly recommended) Cache the image on the nodes you use most, so the runner does not pull the full image on each deploy and VMs start faster. An uncached image pull can take several minutes; a cached one starts in seconds. You can do this from the Orka UI or with the addImageToCache API. Target specific
nodes, a set oftags, orallnodes:Caching runs asynchronously per node. If you schedule builds onto specific nodes with the
tag,tag_required, ornodepool settings, cache the image on those nodes.
Configure pool.yml
The pool.yml file defines the VM pool and the Orka connection details used to run your builds. A pool is a group of VMs that the runner hands out to builds. The runner can keep VMs warm (ready to use) or provision them on demand.
On the host where you run the runner, create a
/runnerfolder andcdinto it:In the
/runnerfolder, create apool.ymlfile.Modify
pool.ymlas described in the following example and the Pool settings reference. You can configure multiple pools inpool.yml, but you can only specify one pool (byname) in each Build (CI) stage in Harness.
Pool settings reference
Instance settings
name
Yes
Unique identifier of the pool. You specify this name in Harness when you set up the CI stage build infrastructure.
type
Yes
Must be orka.
pool
Yes
Warm pool size. The number of VMs kept in a ready state. Use 0 to provision VMs on demand.
limit
Yes
Maximum number of VMs the runner creates at any time, including warm VMs. Each Orka node runs at most two macOS VMs, so a useful limit cannot exceed 2 × the number of eligible nodes (fewer if node or tag_required restricts placement).
default
No
Set to true to use this pool when a stage does not specify a pool name.
platform.os
Yes
Must be darwin.
platform.arch
Yes
Must be arm64. Orka OCI images are Apple-silicon only.
Spec settings
controller_url
Yes
Your Orka API URL (the same URL you pass to orka3 config set --api-url). Must be reachable from the runner. (The setting name is controller_url for historical reasons.)
namespace
Yes
The Orka namespace that VMs are deployed into.
token
Yes
Orka service account token. Leave it empty in pool.yml and supply it with the ORKA_TOKEN environment variable so the token stays out of the file. Go to Start the runner for the full steps.
vm_config
Yes*
The name of a predefined Orka VM configuration to deploy. An Orka VM config is a reusable template (created through Orka's VM Configs API or UI) that bundles an image with resource settings. Required unless you set image. If both are set, the runner uses vm_config (this is runner behavior; Orka itself allows deploying a VM config with a different image).
image
Yes*
The OCI image reference to deploy, pushed with vmPush (for example, ghcr.io/your-org/orka-images/harness-ci:latest). Required unless you set vm_config.
cpu
No
Number of CPU cores requested for the VM.
memory
No
Amount of memory requested for the VM, in GB.
timeout
No
Per-VM provision timeout, in seconds. 0 uses the driver default (10 minutes).
tag
No
An Orka node tag. Schedules the VM onto nodes that have this tag.
tag_required
No
Whether tag is mandatory. If true, Orka deploys the VM only on a node that has tag and fails if none is available. If false (default), tag is a preference and Orka falls back to any available node.
node
No
Pin the VM to a specific Orka node.
scheduler
No
The Orka scheduler used to place the VM. Leave unset to use the cluster default.
vnc
No
Set to true to enable VNC access to the VM.
display_width, display_height, display_dpi
No
Virtual display resolution and DPI for the VM.
custom_metadata
No
Extra Orka customMetadata key/value pairs to pass to the VM. The runner's own startup-script metadata key takes precedence over a collision.
vm_username
No
Login user that lite-engine and build steps run as, instead of root. The runner starts lite-engine as this user with HOME set to /Users/<vm_username>. Leave unset to run as root.
* Set either vm_config or image. If you set both, the runner uses vm_config.
Install the delegate and runner
Install a Harness Docker Delegate and the VM runner on the host you chose.
Start the runner
Store the Orka token in an environment file so it stays out of pool.yml, and load it with the runner's --envfile flag.
In the
/runnerfolder, create a.envfile and add your Orka token:Restrict the file's permissions:
Start the runner:
This command mounts the
/runnervolume into the runner container, which provides access topool.ymland.env, and exposes port 3000. The runner readsORKA_TOKENfrom the environment file and uses it as the Orka service account token.To use
sudoand a different runner directory path, modify the command, for example:
Install the delegate
Install a Harness Docker Delegate on the same host as the runner:
In Harness, go to Account Settings, select Account Resources, and then select Delegates.
You can also create delegates at the project scope. In your Harness project, select Project Settings, and then select Delegates.
Select New Delegate or Install Delegate.
Select Docker.
Enter a Delegate Name.
Copy the delegate install command and paste it in a text editor.
To the first line, add
--network host, and, if required,sudo. The delegate is a JVM and needs at least 4 GB of memory. For example:The
--network hostoption lets the delegate reach the runner athttp://localhost:3000without additional configuration.Run the delegate install command on the host where the runner is running.
Go to Delegate installation overview to learn about delegates and delegate installation.
Verify connectivity
Verify that the delegate and runner containers are running correctly. You might need to wait a few minutes for both processes to start. You can run the following commands to check the process status:
In the Harness UI, verify that the delegate appears in the delegates list. It might take two or three minutes for the delegates list to update. Make sure the Connectivity Status is Connected. If the Connectivity Status is Not Connected, make sure the Docker host can connect to
https://app.harness.io.
The delegate and runner are now installed, registered, and connected.
Specify build infrastructure
Configure your pipeline's Build (CI) stage to use your Orka VMs as build infrastructure.
In Harness, go to the CI pipeline that you want to use the Orka VM build infrastructure.
Select the Build stage, and then select the Infrastructure tab.
Select VMs.
For Operating System, select MacOS.
Enter the Pool Name from your pool.yml.
Save the pipeline.

Delegate selectors with self-managed VM build infrastructures
Although you must install a delegate to use a self-managed VM build infrastructure, you can choose to use a different delegate for executions and cleanups in individual pipelines or stages. To do this, use pipeline-level delegate selectors or stage-level delegate selectors.
Delegate selections take precedence in the following order:
Stage
Pipeline
Platform (build machine delegate)
This means that if delegate selectors are present at the pipeline and stage levels, then these selections override the platform delegate, which is the delegate that you installed alongside the runner. If a stage has a stage-level delegate selector, then it uses that delegate. Stages that do not have stage-level delegate selectors use the pipeline-level selector, if present, or the platform delegate.
Troubleshoot self-managed VM build infrastructure
Go to the CI Knowledge Base for questions and issues related to self-managed VM build infrastructures.
Common Orka-specific issues:
The delegate crash-loops shortly after starting (exit code 137). The delegate ran out of memory. Give it at least
--memory=4g.Builds can't reach the runner. Make sure the delegate runs with
--network hostand that the runner is listening on port3000.VM provisioning fails immediately. Make sure the runner can reach your Orka API URL and that
ORKA_TOKENis a valid, unexpired service account token.The build is stuck after the VM is provisioned. lite-engine did not start on the VM. Confirm the runner host can reach the node on TCP
9079–9080, check that your base image includes the bootstrap daemon, and review/var/log/orka-bootstrap.logand/var/root/lite-engine.logon the VM.Deploy fails with "Requested reserved port range not available on the chosen node(s)". Both reserved port ranges (
9079and9080) are already in use on the candidate node(s), which usually means the node is at capacity (two VMs). Free a VM, add nodes, or lower the pool's concurrency.The first build on a node is slow. The node had to pull the full image. Cache the image on the nodes your pool uses (go to Prepare your Orka base image) so later deploys start in seconds.
VMs are left running after the runner stops. If the runner stops mid-deploy, a VM can be orphaned. List and delete stray VMs in the target namespace from the Orka UI or with
orka3.Deploy fails when
tag_requiredis set. No node has the requiredtag. Add the tag to a node, or settag_required: falseto let Orka fall back to any available node.
Next steps
Go to CI pipeline creation overview to build a pipeline that uses this build infrastructure.
Go to Use Harness Cloud build infrastructure to compare against a managed alternative.
Last updated
Was this helpful?