All guides

ARC runners on AKS with a persistent disk for the work directory

In Kubernetes mode, Actions Runner Controller runs each container job in a second pod, and both pods need the job's files. A volume claim provides them. On AKS an Azure Disk can back that claim.

A laptop showing a stylesheet in a code editor

What the disk is for

Actions Runner Controller (ARC) creates runner pods for the jobs assigned to a runner scale set and deletes a runner once its job is done. A job that uses a container needs one of ARC's container modes. Docker-in-Docker adds a dind container to the runner pod, and GitHub's documentation says that container requires privileged mode. Kubernetes mode has no such container. A hook in the runner asks the cluster for a new pod in the same namespace, and the job container runs there.

The runner pod and the job pod then need the same work directory. GitHub documents two ways to share it. One is a persistent volume, which it names as the recommended option where concurrent write access is required. The other is the kubernetes-novolume mode, which copies the job's files between the pods. This guide sets up the first on AKS.

What AKS creates for each runner

Rendering the chart at version 0.15.1 with the values below gives the runner pod a volume named work, mounted at /home/runner/_work. The volume is a generic ephemeral volume. Kubernetes creates a PersistentVolumeClaim for it when the pod is created, names it after the pod and the volume, and deletes it when the pod is deleted.

AKS ships storage classes for Azure Disks. managed-csi creates a Standard SSD and managed-csi-premium a Premium SSD. Both delete the disk when its persistent volume is deleted, and the default classes wait for the first consumer before they provision. Kubernetes recommends that binding mode for generic ephemeral volumes, because the scheduler stays free to pick the node.

Every runner pod therefore gets a claim of its own, with the size you set, and the claim goes when the pod goes. Plan for an empty work directory at the start of each job.

1. Install the controller

The controller and the runners go in separate namespaces, which GitHub lists as a security practice.

Shell

helm install arc \
  --namespace arc-systems \
  --create-namespace \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller

2. Store the GitHub App credentials

GitHub recommends a GitHub App for runners registered to a repository or an organization. Its authentication page lists the permissions the app needs. Create the secret in the namespace that will hold the runners.

Shell

kubectl create namespace arc-runners
kubectl create secret generic pre-defined-secret \
  --namespace=arc-runners \
  --from-literal=github_app_id=<app-id> \
  --from-literal=github_app_installation_id=<installation-id> \
  --from-literal=github_app_private_key='<contents of the .pem file>'

3. Write the values file

Save this as values.yaml. The size and the runner count are choices of this example, so set your own. Run kubectl get sc first to see the storage classes your cluster has.

YAML

githubConfigUrl: "https://github.com/my-org/my-repo"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 5
containerMode:
  type: "kubernetes"
  kubernetesModeWorkVolumeClaim:
    accessModes: ["ReadWriteOnce"]
    storageClassName: "managed-csi"
    resources:
      requests:
        storage: 10Gi

Install the runner scale set with that file. The release name is the name workflows use in runs-on.

Shell

helm install arc-runner-set \
  --namespace arc-runners \
  -f values.yaml \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set

4. Run a job on the disk

In Kubernetes mode a job with no container fails with the message "Jobs without a job container are forbidden on this runner". Give every job one. This job prints the size and the usage of the filesystem that holds the workspace.

YAML

name: Work disk
on: workflow_dispatch
jobs:
  show-disk:
    runs-on: arc-runner-set
    container:
      image: ubuntu:24.04
    steps:
      - run: df -h "$GITHUB_WORKSPACE"

While the job runs, kubectl get pvc -n arc-runners lists the claim. Its name is the runner pod's name followed by -work.

Limits to plan for

  • One node for both pods. An Azure Disk is mounted as ReadWriteOnce and is available to a single node. The runner image's Dockerfile sets version 0.7.0 of the hooks for this mode, and in that version the hook gives the job pod the node of the runner pod. Leave room on each node for both.
  • Disks per node. The Azure Disks CSI driver has a volume limit for each node that depends on the node's size. Read it with kubectl get CSINode <node-name> -o yaml before you raise maxRunners.
  • Zone-redundant disks. From Kubernetes 1.29, the built-in classes on a cluster spread over availability zones create zone-redundant disks, which cost more than locally redundant ones. Microsoft's answer for cost is a storage class of your own with skuName set to an LRS type.
  • Built-in classes are reconciled. AKS overwrites changes made to them. Put custom settings in a new class.
  • A retain policy leaves disks behind. Kubernetes notes that a class set to retain keeps the storage after the pod is gone, and that cleaning it up is then a separate task. Keep the delete policy for work volumes.
  • The runner can create pods. For this mode the chart gives the runner's service account a role that can create and delete pods, jobs and secrets in its namespace. Keep that namespace for runners only.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides