Sub topic 5
Giving ARC access to GitHub
This chapter assumes you can create Kubernetes secrets with kubectl, read a Helm values file, and have a GitHub organization or repository where you can manage Actions settings. You should also know that the controller is installed once per cluster, while each runner scale set is installed separately. The previous chapters covered the architecture. This one covers how a scale set proves to GitHub that it may register runners.
What ARC needs credentials for
ARC does not receive webhooks from GitHub. The listener pod makes outbound HTTPS calls to the Actions service to ask how many jobs are waiting. To do this, ARC has to authenticate to GitHub for two things:
- Registering the scale set itself, and later removing it, at the repository, organization, or enterprise level named in
githubConfigUrl. - Obtaining short-lived registration tokens, so that each ephemeral runner pod can register once and run one job.
Both operations are done with a long-lived credential that you store in a Kubernetes secret. ARC supports two types of credential:
| Option | What it is | Best for |
|---|---|---|
| Personal access token (PAT) | A token tied to a user account | Trials, a single repository, quick setups |
| GitHub App | An app you create and install on an organization or repository | Production, organizations, higher rate limits |
The secret belongs to the scale set, not to the controller. You create it in the runner namespace, the same namespace where you install the scale set chart. The controller chart does not read it.
Option 1: personal access token
A PAT is the quickest route. The token acts as the user who created it, so the user needs sufficient rights on the target.
Create a personal access token (classic) with these scopes:
| Target in `githubConfigUrl` | Required scope |
|---|---|
| Repository | `repo` |
| Organization | `admin:org` (and `repo` if the runners will serve private repositories) |
| Enterprise | `manage_runners:enterprise` |
For repository-level scale sets, the user must be an admin of that repository. For organization-level scale sets, the user must be an organization owner.
Store the token in a secret under the key github_token. Using --from-literal keeps the token off the Helm command line, so it does not appear in your shell history alongside a helm install command or in the Helm release values.
kubectl create namespace arc-runners
kubectl create secret generic pre-defined-secret \
--namespace arc-runners \
--from-literal=github_token='<YOUR_PAT>'Then reference the secret by name in the scale set values:
githubConfigUrl: "https://github.com/<your-org>/<your-repo>"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 10Downsides of a PAT
- The token is tied to a person. If that person leaves the organization or is deactivated, the token stops working and the runners stop registering.
- The scopes are broad.
admin:orggrants far more than runner management. - All ARC traffic counts against that user's API rate limit.
Option 2: GitHub App
A GitHub App has its own identity, narrower permissions, and a rate limit that scales with the installation. It does not depend on one person's account. Use it for anything beyond a trial.
Create and install the app
- In your organization settings, open Developer settings and create a new GitHub App. Give it a name and a homepage URL. Webhooks are not needed, so you can deactivate them.
- Set the permissions. For a repository-level scale set, grant Repository permissions: Administration (read and write) and Metadata (read). For an organization-level scale set, grant Organization permissions: Self-hosted runners (read and write).
- Create the app, then generate a private key. GitHub downloads a
.pemfile once. Keep it safe. - Install the app on the organization, choosing either all repositories or only the repositories that the scale set will serve.
- Note the App ID from the app's settings page. Note the installation ID from the end of the URL on the installation's settings page (
.../settings/installations/<installation-id>).
Create the secret
A GitHub App secret needs three keys: github_app_id, github_app_installation_id, and github_app_private_key.
kubectl create secret generic pre-defined-secret \
--namespace arc-runners \
--from-literal=github_app_id=123456 \
--from-literal=github_app_installation_id=7890123 \
--from-file=github_app_private_key=./my-app.private-key.pemThe values file looks the same as in the PAT case. Only the content of the secret differs, and ARC detects which kind of credential it holds from the key names.
githubConfigUrl: "https://github.com/<your-org>"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 10How the app authenticates
ARC signs a short-lived JSON Web Token with the private key and exchanges it for an installation access token. Installation tokens expire after one hour, and ARC refreshes them automatically. The long-lived secret is the private key, so protect that file as you would a password.
Passing credentials inline versus by reference
The scale set chart accepts githubConfigSecret in two forms.
As a string, it names an existing secret, as shown above. You manage the secret's lifecycle yourself, for example with an external secrets operator or sealed secrets. This is the recommended form.
As a map, it holds the values inline and the chart creates the secret for you:
githubConfigUrl: "https://github.com/<your-org>"
githubConfigSecret:
github_token: "<YOUR_PAT>"The inline form is convenient in a lab. In production, it places the credential in the Helm release values, which anyone with access to the release in the cluster can read, and in whatever file or pipeline supplies -f or --set.
Verify the credential works
After installing the scale set (the next chapters show the full command), check that registration succeeded:
kubectl get autoscalingrunnersets -n arc-runners
kubectl get pods -n arc-systemsA working credential results in a listener pod running in arc-systems. The scale set should also appear in GitHub under Settings, Actions, Runner groups, or in the runners list for the organization or repository.
If the credential fails, the listener never appears. The error is in the controller log and on the AutoscalingRunnerSet resource:
kubectl describe autoscalingrunnerset -n arc-runners
kubectl logs -n arc-systems deploy/arc-gha-rs-controllerThe deployment name depends on the Helm release name you gave the controller. Use kubectl get deploy -n arc-systems to find it.
Common errors
| Symptom | Likely cause |
|---|---|
| Log line with HTTP 401 or "Bad credentials" | Token expired, revoked, or copied with extra whitespace |
| HTTP 403 or 404 when registering | Missing scope or app permission, or the app is not installed on that repository |
| Secret not found | Secret created in a different namespace from the scale set |
| App authentication fails with a key parse error | The private key was pasted through `--from-literal` and lost its line breaks. Use `--from-file` |
| Scale set registers, then stops after a while | PAT owner lost access, or the PAT reached its expiry date |
| Wrong `githubConfigUrl` level | The scope or permission covers the repository, but the URL points at the organization (or the reverse) |
Two details cause many of these failures. First, the secret name in githubConfigSecret must match exactly and must live in the scale set's namespace. Second, the permission or scope must match the level in githubConfigUrl: a repository-level app permission does not allow organization-level registration.
Rotating credentials
To rotate a PAT, create the new token, update the secret value, and delete the old token. To rotate a GitHub App key, generate a second private key in the app settings, update the secret, then delete the old key. GitHub allows several active keys at once, so there is no gap.
kubectl create secret generic pre-defined-secret \
--namespace arc-runners \
--from-file=github_app_private_key=./new-key.pem \
--from-literal=github_app_id=123456 \
--from-literal=github_app_installation_id=7890123 \
--dry-run=client -o yaml | kubectl apply -f -Recreate the full secret, with every key, as shown. Applying a secret that contains only one key replaces the others. After a change, check the listener and controller logs. If the controller keeps using old credentials, restart it with kubectl rollout restart on the controller deployment.
Choosing between them
Choose a PAT when the cluster is a test environment, the scale set serves one repository, and a person is accountable for the token. Choose a GitHub App when the scale set serves an organization, when the runners are a shared service, or when you want the credential to survive staff changes. The app's narrower permissions and independent rate limit matter once several scale sets share one organization.
Exercise
A scale set was installed in the namespace arc-runners with githubConfigSecret set to my-secret. You created my-secret in arc-systems, where the controller runs. Will the listener start, and why?
Show answer
No. The secret is read for the scale set, so it must exist in the scale set's own namespace (arc-runners). The controller's namespace does not matter. Create my-secret in arc-runners and check the AutoscalingRunnerSet with kubectl describe.
Exercise
You create a GitHub App secret with --from-literal=githubappprivate_key="$(cat key.pem)" and authentication fails with a parse error. What is the likely cause and the fix?
Show answer
The PEM key's line breaks were lost or altered when passed as a literal. Recreate the secret with --from-file=githubappprivate_key=./key.pem so the file is stored byte for byte.
Exercise
Give two reasons to prefer a GitHub App over a PAT for an organization-level scale set.
Show answer
The app has its own identity, so the runners keep working when an employee leaves. It also uses narrower permissions (Self-hosted runners) and has its own rate limit, instead of a broad scope such as admin:org and a single user's rate limit.