Skip to main content
Running CI jobs on your own cluster is in preview.
AutoPilot for CI can send a job to spare capacity on your own Kubernetes cluster. A dispatcher from the agent runtime chart starts a GitHub Actions runner pod for each job through GitHub’s actions-runner-controller. The pod takes only that job and is removed when the job ends. CostGraph registers each runner through the CostGraph GitHub App, so you don’t need your own GitHub App, a personal access token, or a runner scale set. To route to runner scale sets you already run, see Use runner sets you manage.

Requirements

  • AutoPilot for CI is set up as described in Requirements.
  • An owner of the GitHub organization has approved the CostGraph GitHub App’s Self-hosted runners organization permission, set to Read and write, and its Workflow job event. Until then, the cluster is skipped with reason github_app_reapproval.
  • The CostGraph operator runs in the cluster.
  • Every node has a price. Nodes on a supported cloud are priced from their instance type. Other nodes need a pricing ID.
  • Jobs run on Linux. Jobs that use Docker need Kubernetes 1.29 or later.

Install

Install actions-runner-controller and the dispatcher with one release of the costgraph-agent-runtime chart.

Create the secrets

The dispatcher can use the operator’s CostGraph API key. In CostGraph, add the sandbox:worker and deployment:register scopes to that key. The first lets the dispatcher take jobs. The second lets the cluster pull the dispatcher image from registry.costgraph.ai. To use a separate key, create one with the same two scopes. The chart reads the key from a secret under api-key and needs a pull secret for the registry. Create both in the runtime’s namespace.
The following commands copy the key from the operator’s secret. For an operator release named costgraph-operator, the secret is costgraph-operator-credentials in the costgraph namespace. If you set global.existingSecret, use that secret instead.

Install the chart

Set ciRunner.cluster to the global.clusterName of the CostGraph operator in this cluster. arcController.enabled: true installs actions-runner-controller 0.15.1 with the release.
Write the values to values.yaml.
Install the chart.
After the dispatcher connects, AutoPilot considers the cluster for every Linux job that fits it. The routing job’s log lists it under the kubernetes provider. To disconnect the cluster, uninstall the release or remove the sandbox:worker scope from the key.

Chart values

One release runs runners on one architecture. To run x86_64 and arm64 jobs on the same cluster, install a second release with another workerName and the other arch.

Use an actions-runner-controller you already run

Set arcController.enabled: false and name the controller’s service account. The chart lets that controller create runner pods in the release namespace. With the CostGraph operator chart’s arc.enabled, the service account is costgraph-arc-controller in the operator’s namespace.

How each job runs

AutoPilot sends a job to the cluster only when a ready node of the release’s architecture has enough unrequested CPU and memory for the runner pod. The pod requests the CPU and memory AutoPilot measured for the job. Before the job is measured, it requests half the default runner’s vCPUs, at least 1, and up to 2 GB of memory. When maxRunners pods are running, AutoPilot sends no more jobs to the cluster until one finishes. A job that uses Docker gets a privileged Docker-in-Docker sidecar in its runner pod. If the cluster refuses privileged pods in the release namespace, AutoPilot stops sending Docker jobs to the cluster. Jobs without Docker still go there. Routing to the cluster otherwise works like any other runner. Your policy, trials, and provider limits apply, with the cluster under the kubernetes provider. A cluster is skipped with reason target_offline when its dispatcher has not connected in the last 10 minutes or its operator has stopped reporting. To limit which workflows use the cluster, set providers on the routing job. To send every job that fits to the cluster, set pin: kubernetes. Refer to Pin a workflow to a provider.

What a job costs

The capacity a cluster job uses is already paid for, so the job counts as $0 for routing and savings. CostGraph still records the node’s share next to every run, so you can see what the cluster spent. The share is the node’s hourly price times the larger of the pod’s share of the node’s CPU and of its memory.

Price nodes without an instance type

A cluster with no priced node that fits the job is skipped with reason not_priced. Nodes without a cloud instance type, such as bare metal, on-premises, or kind nodes, need a compute rate and a pricing ID label.

Use runner sets you manage

AutoPilot also routes to runner scale sets you run with actions-runner-controller. The CostGraph operator reports each runner set, and the runner set’s name is the label AutoPilot returns. Runner sets follow the same capacity and cost rules as the dispatcher’s runners.
  • AutoPilot matches jobs on the CPU and memory requests of the runner container. Without requests, it uses the job’s measured usage or the default runner’s size.
  • Jobs that use Docker go only to runner sets in Docker-in-Docker mode (containerMode.type: dind).
  • A runner set that is not running is skipped with reason cluster_unavailable.
  • A runner set registered for a GitHub enterprise can take jobs from every organization of that enterprise you connect to CostGraph.
A runner set registers its runners with a credential you own, because the CostGraph GitHub App’s private key cannot live in your cluster. We recommend a GitHub App of your own. A runner set registered for a GitHub enterprise needs a personal access token instead. Refer to GitHub’s authentication guide.

Create your own GitHub App

Create a GitHub App in your organization’s Settings > Developer settings > GitHub Apps, with Webhook turned off, and install it on the organization. For an organization runner set, give it Self-hosted runners set to Read and write under Organization permissions. For a repository runner set, give it Administration set to Read and write under Repository permissions. Both need Metadata set to Read-only. Create the secret in the runner set’s namespace from the app’s App ID, its installation ID, and a private key you generate on its General page. The installation ID is the number at the end of the installation’s URL. With the CostGraph operator chart, the namespace is the operator’s, costgraph.
To use a personal access token instead, create a classic token. Give it the admin:org scope for an organization runner set or the repo scope for a repository runner set. Store it in the same secret as github_token.

Install a runner set

You can install a runner set with GitHub’s charts or with the CostGraph operator chart. The operator finds runner sets either way.
Follow GitHub’s quickstart and deploy a runner scale set. Set githubConfigSecret to the secret from Create your own GitHub App.

Public repositories

Runners on your cluster join your organization’s Default runner group unless a runner set names another. By default, GitHub doesn’t let that group run jobs from public repositories, so those jobs never reach your cluster. To allow them, an organization owner opens Settings > Actions > Runner groups in GitHub and turns on Allow public repositories for the group. The group must also allow every repository you want routed there. Read GitHub’s guidance on self-hosted runners and public repositories before you turn it on.