Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

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/9080 to lite-engine (port 9079) inside the guest. So the runner host must be able to reach every Orka node on TCP 9079–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.

Orka 4.0 adds native boot scripts through the userdata API field (--userdata in the CLI); a future runner release will use that directly. Until then (and always on Orka 3.x clusters, or on images without the Orka 4.0 VM Tools), the launchd daemon described here is required, so these steps set it up either way. This is separate from the runner's own user_data pool setting, which overrides the generated startup script.

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.

  1. 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 uses plutil to parse the metadata JSON, which is built into macOS and needs no extra tools:

    Set its owner and permissions:

  2. Create the launchd daemon /Library/LaunchDaemons/com.harness.orka-bootstrap.plist. The EnvironmentVariables dictionary is required: launchd jobs start with a minimal PATH that excludes /opt/homebrew/bin, and with no $HOME, both of which break the startup script.

    Set its owner and permissions:

  3. Validate the daemon:

    Copying the plist into place is enough; it loads automatically on the next boot. Do not run launchctl bootstrap on the template VM: that starts the script immediately, and it fails after about a minute because there is no VM metadata to fetch yet.

  4. Install the tools your pipelines use so they are on the PATH (for example, Git and any language toolchains). The runner's startup script places lite-engine and its helper binaries under /opt/homebrew/bin and /usr/local/bin, so make sure those directories exist.

  5. Clear the bootstrap logs so the saved image starts clean:

  6. Push the image to an OCI registry with vmPush (for example, GitHub Packages or Harbor). You reference the pushed image as image in pool.yml. (Orka also has an older imageSave that 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:

  7. (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 of tags, or all nodes:

    Caching runs asynchronously per node. If you schedule builds onto specific nodes with the tag, tag_required, or node pool 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.

  1. On the host where you run the runner, create a /runner folder and cd into it:

  2. In the /runner folder, create a pool.yml file.

  3. Modify pool.yml as described in the following example and the Pool settings reference. You can configure multiple pools in pool.yml, but you can only specify one pool (by name) in each Build (CI) stage in Harness.

Pool settings reference

Instance settings

Setting
Required
Description

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

Setting
Required
Description

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.

Advanced: The user_data and user_data_path settings override the startup script the runner generates for the VM. The default startup script already downloads and starts lite-engine, so only set these if you need to customize the VM boot sequence. An incorrect override prevents lite-engine from starting. (This is the runner's own startup-script template, not Orka's native userdata field in Orka 4.0.)

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.

  1. In the /runner folder, create a .env file and add your Orka token:

  2. Restrict the file's permissions:

  3. Start the runner:

    This command mounts the /runner volume into the runner container, which provides access to pool.yml and .env, and exposes port 3000. The runner reads ORKA_TOKEN from the environment file and uses it as the Orka service account token.

    To use sudo and a different runner directory path, modify the command, for example:

WHAT DOES THE RUNNER DO?

When a build starts, the delegate receives a request for a VM on which to run the build. The delegate forwards the request to the runner, which then allocates a VM from the warm pool (specified by pool in pool.yml) or, if necessary, provisions a new VM on your Orka cluster (up to the limit specified in pool.yml).

Install the delegate

Install a Harness Docker Delegate on the same host as the runner:

  1. 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.

  2. Select New Delegate or Install Delegate.

  3. Select Docker.

  4. Enter a Delegate Name.

  5. Copy the delegate install command and paste it in a text editor.

  6. 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 host option lets the delegate reach the runner at http://localhost:3000 without additional configuration.

  7. Run the delegate install command on the host where the runner is running.

The delegate install command uses the default authentication token for your Harness account. If you want to use a different token, you can create a token and then specify it in the delegate install command:

  1. In Harness, go to Account Settings, then Account Resources, and then select Delegates.

  2. Select Tokens in the header, and then select New Token.

  3. Enter a token name and select Apply to generate a token.

  4. Copy the token and paste it in the value for DELEGATE_TOKEN.

Go to Delegate installation overview to learn about delegates and delegate installation.

Verify connectivity

  1. 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:

  2. 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.

  1. In Harness, go to the CI pipeline that you want to use the Orka VM build infrastructure.

  2. Select the Build stage, and then select the Infrastructure tab.

  3. Select VMs.

  4. For Operating System, select MacOS.

  5. Enter the Pool Name from your pool.yml.

  6. Save the pipeline.

Delegate selectors with self-managed VM build infrastructures

Delegate selectors for self-managed VM build infrastructures are behind the feature flag CI_ENABLE_VM_DELEGATE_SELECTOR. Contact Harness Support to enable the feature.

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:

  1. Stage

  2. Pipeline

  3. 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 host and that the runner is listening on port 3000.

  • VM provisioning fails immediately. Make sure the runner can reach your Orka API URL and that ORKA_TOKEN is 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.log and /var/root/lite-engine.log on the VM.

  • Deploy fails with "Requested reserved port range not available on the chosen node(s)". Both reserved port ranges (9079 and 9080) 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_required is set. No node has the required tag. Add the tag to a node, or set tag_required: false to let Orka fall back to any available node.

Next steps

Last updated

Was this helpful?