Running CI jobs on your own cluster is in preview.
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 thecostgraph-agent-runtime chart.
Create the secrets
The dispatcher can use the operator’s CostGraph API key. In CostGraph, add thesandbox: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.
- kubectl
- External Secrets Operator
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
SetciRunner.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.
- Helm
- Argo CD
Write the values to Install the chart.
values.yaml.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
SetarcController.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. WhenmaxRunners 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 reasonnot_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
runnercontainer. 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.
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.
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.- GitHub's charts
- CostGraph operator chart
Follow GitHub’s
quickstart
and deploy a runner scale set.
Set
githubConfigSecret to the secret from
Create your own GitHub App.