Skip to Content
kosemdocs
Concepts

Self-hosted runners

How self-hosted runner pools run kosem environments in isolated VMs on your Linux hosts and Macs, and how placement, architectures and security work.

Self-hosted runners let you run kosem environments on your Linux hosts or Apple silicon Macs instead of kosem-managed machines. You install the kosem-runner daemon on each host and group hosts into runner pools that projects select for agents and standalone environments.

Pools and runners

A runner pool is a group of hosts that environments can run on:

  • Organization pools belong to your organization and can be shared with all projects or selected projects, as organization registries are.
  • Project pools belong to a single project and aren't shared with other projects.

A runner is one host registered in a pool. When you add a runner, kosem creates a one-time registration token (krt_…, valid for 1 hour) and stores only its hash. The host uses that token once to register its Ed25519 public key and hardware capacity. From then on, the runner signs short-lived credentials with its private key and polls https://api.kosem.ai every few seconds. kosem never opens inbound connections to your hosts.

Each runner has a state:

  • PENDING (Not registered): waiting for a host to register with its one-time token.
  • EXPIRED (Token expired): the token expired unused; the runner no longer counts toward your quota.
  • ONLINE: syncing with kosem and ready to run environments.
  • OFFLINE: hasn't synced for 30 seconds.

You can also pause an online or offline runner so kosem places no new environments on it while keeping its existing environments intact.

How environments run on a host

Every environment on a runner runs in an isolated VM with a full Linux kernel, persistent disk and root access confined to the guest, so tools such as sudo dockerd work inside. Commands, interactive shells, files, secrets, access profiles, idle stop and purge work the same as on kosem-managed machines.

  • Linux (x86_64 with KVM): runs each environment as a Kata Containers microVM with Cloud Hypervisor on an isolated containerd instance. The installer doesn't modify Docker or containerd already on the host. nftables rules block environments from reaching the host, cloud metadata (169.254.169.254) and one another.
  • macOS (Apple silicon, macOS 26 or later): runs each environment in a Linux VM through Apple's container runtime. pf firewall rules block environments from reaching the Mac, its local network, loopback, multicast, cloud metadata addresses and IPv6 while allowing gateway DNS and DHCP. While any environment runs, the runner keeps an idle Mac awake, though closing a MacBook lid still sleeps it.

Private container images work on both Linux and Mac pools through your organization's or project's registries. The runner requests registry credentials from kosem only when pulling an image and never writes them to disk. Prepared images accelerate starts on kosem-managed machines; self-hosted runners pull images directly from their registries.

One architecture per pool

Every runner in a pool must share one CPU architecture, set by the first host that registers (amd64 for Linux x86_64 hosts, arm64 for Apple silicon Macs). kosem refuses hosts of a different architecture in the same pool and checks every environment's image against the pool's architecture before starting it.

Mac pools accept linux/arm64 images only. kosem doesn't run linux/amd64 images under Rosetta on Macs so environments run at native speed.

Placement, capacity and disk affinity

When an environment needs to start in a pool, kosem places it on the online, unpaused runner with enough room and the most free memory. If no runner in the pool has room, the environment waits and starts automatically as soon as capacity frees up or a runner comes online.

A runner offers its host's resources minus a host reserve:

  • Linux: reserves 2 GiB of memory (or 10% of RAM, whichever is larger) and 10% of the state filesystem.
  • macOS: reserves 4 GiB of memory (or 25% of RAM, whichever is larger) and 10% of free space plus existing environment volumes.

You can set lower ceilings during installation with --max-vcpus, --max-memory-gib and --max-disk-gib. When placing environments, kosem counts each running or starting environment's full memory plus 1 GiB of VM overhead, half its vCPUs (rounded up), and the full disk of every placed environment on the runner (running or stopped).

Because an environment's disk is stored on its host, it stays on that runner across stops and starts:

  • While its runner is offline, the environment waits until the runner reconnects.
  • Pausing a runner stops new placements without disturbing environments already on it.
  • Deleting a runner revokes its credentials and wipes its VMs and disks. Any remaining environments lose their disks and start fresh from their images on another runner in the pool.
  • Changing an agent's pool deletes its current environment and disk; the agent gets a fresh environment in the new pool on its next command.
  • On macOS, an environment's disk size is fixed at creation because Apple's container volumes can't grow.

Quotas, billing and policies

Environments on self-hosted runners don't incur kosem cloud compute or disk charges and don't consume your organization's cloud vCPU, memory or disk quotas. They still count toward your organization's total Environments quota, and each registered or pending runner counts toward your plan's Self-hosted runners quota (Limits and quotas).

On Team and Enterprise, Owners and Policy Admins can enforce the Require self-hosted policy (environments.selfHostedRequired) at the organization or project level so environments never run on kosem-managed machines.

Why it works this way

  • Outbound-only sync. Hosts never expose inbound ports or SSH to kosem. Every request uses a short-lived token signed by the host's Ed25519 key, and kosem keeps only the public key.
  • Host trust boundary. VM isolation protects the host and separates environments from one another, but anyone with root access on a runner host can inspect what its environments run, including command output, bound secrets and issued credentials. Use hosts you trust and grant Environment Admin carefully.
  • Explicit host upgrades. kosem updates its in-VM environment tools automatically, while kosem-runner upgrades only when you run kosem-runner upgrade on the host so service restarts happen on your schedule. Running environments survive an upgrade.

Who can do what

ToYou need, on the organization or project
See runner pools, runners and the environments placed on a runnerAny basic role, Environment Viewer, Environment User or Environment Admin
Create, update and delete runner pools, and add, pause, resume and delete runnersOwner, Editor or Environment Admin (on the organization for organization pools, or a project)
Share an organization runner pool with projectsOwner, on the organization

On this page