Installation
This guide covers a complete installation of gh-maintainer on Kubernetes: prerequisites, the three secrets, basic auth for Traefik and ingress-nginx, TLS with a private CA, deployment from GitHub Container Registry with your own copy of the example kustomize overlay, the switch from dry run to live, and the checks to run after the first job.
If you want the shortest path, start with the quick start and come back here for details.
Prerequisites
Section titled “Prerequisites”Cluster
Section titled “Cluster”The manifests in deploy/base are install-neutral. They work on any conformant cluster and expect:
| Requirement | What the base uses |
|---|---|
| Ingress controller | The cluster’s default IngressClass, or set one in your overlay. Traefik and ingress-nginx are supported. The NetworkPolicy admits controllers in the namespaces ingress, ingress-nginx, traefik and kube-system. |
| Storage | The cluster’s default StorageClass, or set one in your overlay. 1 Gi ReadWriteOnce for the status server’s SQLite database. |
| cert-manager | Optional. Only the private CA component needs it. |
| NetworkPolicy enforcement | A CNI that enforces NetworkPolicy, such as Calico (the microk8s default) |
| Architecture | linux/amd64 nodes (the scanner binaries are amd64 only) |
Check which classes your cluster marks as default:
kubectl get ingressclass # look for ingressclass.kubernetes.io/is-default-classkubectl get storageclass # look for "(default)"As an example, on microk8s enable the addons. microk8s names the IngressClass public and the StorageClass microk8s-hostpath; if kubectl get doesn’t show them as default, set them in your overlay:
microk8s enable dns ingress cert-manager hostpath-storagemicrok8s status --wait-readykubectl get ingressclass,storageclasskubectl -n cert-manager get podsCheck that NetworkPolicy is enforced. With Calico, this lists running pods:
kubectl -n kube-system get pods -l k8s-app=calico-nodeYou set the install-specific values (your GitHub owner, host, and optionally classes, TLS and Traefik auth) in your own overlay, see Use your own overlay and Adapt to your cluster.
Workstation tools
Section titled “Workstation tools”kubectl(with built-in kustomize)htpasswd(Debian/Ubuntu:apache2-utils) for the basic-auth fileopensslfor the event token- the
claudeCLI, forclaude setup-token docker, only if you build the images yourself
Create the secrets
Section titled “Create the secrets”gh-maintainer needs three tokens in the Secret gh-maintainer, plus a basic-auth secret for the ingress.
GitHub fine-grained token (GITHUB_TOKEN)
Section titled “GitHub fine-grained token (GITHUB_TOKEN)”Create the token at GitHub → Settings → Developer settings → Fine-grained tokens:
- Resource owner: the user or organization gh-maintainer maintains (the
ownerin the configuration). - Repository access: All repositories.
- Repository permissions:
| Permission | Access | Used for |
|---|---|---|
| Contents | Read and write | Cloning, pushing fixes to Dependabot branches, deleting branches |
| Pull requests | Read and write | Listing, merging and commenting on pull requests |
| Administration | Read-only | Reading branch protection for the hygiene check |
| Actions | Read-only | Reading failed CI job logs for the fixer |
| Dependabot alerts | Read-only | Security findings |
| Code scanning alerts | Read-only | Security findings |
| Secret scanning alerts | Read-only | Security findings |
| Metadata | Read-only | Mandatory for every fine-grained token |
Do not grant Workflows. The fixer refuses to push any change under .github/, because a push from the bot token could add or modify a workflow that then runs with the repository’s secrets before a human approves it. Without the Workflows permission, GitHub also rejects such a push server-side.
The status server uses the same token for Approve (merge) and Reject (comment).
Claude OAuth token (CLAUDE_CODE_OAUTH_TOKEN)
Section titled “Claude OAuth token (CLAUDE_CODE_OAUTH_TOKEN)”The fixer runs Claude Code with your Claude subscription:
claude setup-token # prints a long-lived OAuth token for your subscriptionEvent token (EVENT_TOKEN)
Section titled “Event token (EVENT_TOKEN)”The agent uses this bearer token to POST events to the status server:
openssl rand -hex 32Apply the app secret
Section titled “Apply the app secret”The namespace must exist first:
kubectl apply -f deploy/base/namespace.yaml
cp deploy/secret.example.yaml deploy/secret.yamlchmod 600 deploy/secret.yaml # before any real value goes in$EDITOR deploy/secret.yaml # replace the three REPLACE_ME_* valueskubectl apply -f deploy/secret.yamlshred -u deploy/secret.yaml 2>/dev/null || rm -f deploy/secret.yamlCheck the keys without printing the values:
kubectl -n gh-maintainer get secret gh-maintainer \ -o go-template='{{range $k, $v := .data}}{{$k}}{{"\n"}}{{end}}'# expected: CLAUDE_CODE_OAUTH_TOKEN, EVENT_TOKEN, GITHUB_TOKENThe agent reads the tokens as files under /secrets (a secret volume with mode 0400), never from environment variables. The status server receives EVENT_TOKEN and GITHUB_TOKEN as environment variables.
Protect the widget with basic auth
Section titled “Protect the widget with basic auth”The widget and the approve/reject routes sit behind HTTP basic auth at the ingress. Create an htpasswd file with bcrypt hashes:
htpasswd -cB deploy/auth.htpasswd <user>The base Ingress carries the ingress-nginx annotations. Traefik needs the deploy/components/traefik component in your overlay. Create the secret for the controller you run.
ingress-nginx
Section titled “ingress-nginx”ingress-nginx reads the nginx.ingress.kubernetes.io/auth-* annotations in the base and the Secret gh-maintainer-auth with the key auth. Remove the Traefik component from your overlay.
kubectl -n gh-maintainer create secret generic gh-maintainer-auth \ --from-file=auth=deploy/auth.htpasswdTraefik
Section titled “Traefik”Traefik (for example k3s, or the ingress addon on current microk8s) ignores the nginx annotations. Keep the component deploy/components/traefik in your overlay. It adds the basic-auth Middleware and patches the Ingress with these annotations:
traefik.ingress.kubernetes.io/router.middlewares: gh-maintainer-basic-auth@kubernetescrdtraefik.ingress.kubernetes.io/router.entrypoints: websecuretraefik.ingress.kubernetes.io/router.tls: "true"
The Middleware reads the Secret gh-maintainer-traefik-auth, which must contain exactly one key, users:
kubectl -n gh-maintainer create secret generic gh-maintainer-traefik-auth \ --from-file=users=deploy/auth.htpasswdAfter deploying, check that auth is enforced. Without credentials you must get 401:
curl -sk -o /dev/null -w '%{http_code}\n' https://gh-maintainer.example.com/stateUse a dedicated htpasswd user for the desktop app, because the app stores its password in plain text.
Deploy from GHCR
Section titled “Deploy from GHCR”The Release workflow pushes two linux/amd64 images:
ghcr.io/pierrejochem/gh-maintainer-agentghcr.io/pierrejochem/gh-maintainer-status-server
| Tag | Points to |
|---|---|
main |
The latest build of the main branch |
sha-<short> |
One specific commit, such as sha-0893c6b |
<version>, <major>.<minor> |
A tagged release, such as 1.3.0 and 1.3. Recommended for production. |
The overlay deploy/overlays/ghcr reuses deploy/base with these images and imagePullPolicy: IfNotPresent. Like the base, it contains placeholders (owner: CHANGE_ME, OWNER=CHANGE_ME, host gh-maintainer.example.com), so don’t apply it directly. Build your own overlay on top of it.
Use your own overlay (recommended)
Section titled “Use your own overlay (recommended)”An overlay keeps your settings out of the shared base, pins the image tag and patches the config. The repository ships a template in deploy/overlays/example. Copy it, replace the placeholders, review the render and apply:
cp -r deploy/overlays/example deploy/overlays/mine$EDITOR deploy/overlays/mine/kustomization.yaml deploy/overlays/mine/config.yamlkubectl kustomize deploy/overlays/mine | grep -E 'image:|host:|owner:|OWNER' -A1 # reviewkubectl apply -k deploy/overlays/mineCreate the secrets before the first apply.
Placeholders to replace
Section titled “Placeholders to replace”| Where | Placeholder | Set it to |
|---|---|---|
config.yaml |
owner: CHANGE_ME |
Your GitHub user or organization name. See owner. |
kustomization.yaml, status-server patch |
value: CHANGE_ME |
The same name. The status server uses it to merge and comment on approvals. |
kustomization.yaml, Ingress patch |
gh-maintainer.example.com (twice) |
Your hostname. DNS must point at the ingress controller. |
kustomization.yaml, Certificate patch |
gh-maintainer.example.com (twice) |
The same hostname. Delete this patch if you remove the private CA component. |
kustomization.yaml, images: |
newTag: "1.3.0" |
The release you want (see releases), or a build tag such as sha-0893c6b. Avoid main in production: with IfNotPresent, a node keeps the image it already has. |
config.yaml replaces the whole config.yaml value of the base ConfigMap, so it must contain every setting you want, not only the changed ones. It starts with dryRun: true. All configuration keys are described in the configuration reference.
The status-server patch starts with a JSON patch test operation:
- op: test path: /spec/template/spec/containers/0/env/1/name value: OWNER- op: replace path: /spec/template/spec/containers/0/env/1/value value: CHANGE_ME # your GitHub user or organizationThe test makes the render fail if a future base moves OWNER away from the second environment variable, instead of silently overwriting another variable.
Components: keep or remove
Section titled “Components: keep or remove”The template enables two optional kustomize components from deploy/components. Delete the line of each one you don’t need under components::
| Component | Keep it when | Remove it when |
|---|---|---|
../../components/traefik |
Your ingress controller is Traefik (k3s, the microk8s ingress addon). It adds the basic-auth Middleware and the Traefik router annotations, see Traefik. |
You run ingress-nginx. The base already carries the nginx auth annotations. |
../../components/private-ca |
You want cert-manager to issue the TLS certificate from a small private CA, see TLS and the private CA. | You bring your own certificate in the Secret gh-maintainer-tls, or use your own issuer or ACME. Also delete the Certificate patch. |
For a real-world example, see deploy/overlays/pjo-vpn, the maintainer’s own overlay for a microk8s cluster with Traefik and the private CA. Don’t copy it as a template: it contains that installation’s owner, host and classes.
Adapt to your cluster
Section titled “Adapt to your cluster”The template contains commented patches for the parts that differ between clusters. Uncomment the ones you need:
- IngressClass: if your cluster has no default IngressClass, add
/spec/ingressClassNamein the Ingress patch, such astraefik,nginxorpublicon microk8s. - StorageClass: if your cluster has no default StorageClass, add
/spec/storageClassNameto thestatus-server-dataPersistentVolumeClaim, such aslocal-pathormicrok8s-hostpath. - NetworkPolicy: the base admits the ingress namespaces
ingress,ingress-nginx,traefikandkube-system. To allow only your controller’s namespace, replace thenamespaceSelectorofstatus-server-ingress.
- target: { group: networking.k8s.io, version: v1, kind: NetworkPolicy, name: status-server-ingress } patch: |- - op: replace path: /spec/ingress/0/from/0/namespaceSelector value: matchLabels: kubernetes.io/metadata.name: ingress-nginxThe NetworkPolicy matters: the status server only accepts traffic from the ingress controller’s namespace and from agent pods. If your controller runs in another namespace, the widget gets 502 or 504 errors until you patch it.
Use a release manifest
Section titled “Use a release manifest”Every vX.Y.Z GitHub release carries the rendered manifests for that version, built from deploy/overlays/ghcr:
gh release download v1.3.0 -R pierrejochem/gh-maintainer -p 'gh-maintainer-1.3.0.yaml'The release manifest contains the same placeholders as the base: CHANGE_ME for the owner (twice), gh-maintainer.example.com for the host, dryRun: true, and neither the Traefik nor the private CA component. Edit those values in the file before kubectl apply -f gh-maintainer-1.3.0.yaml, or, better, use an overlay and pin newTag: 1.2.3.
Registry access
Section titled “Registry access”GHCR packages can be private. The kubelet pulls anonymously, so if a pull fails with an authorization error, give the cluster a pull secret. Create a classic personal access token with only read:packages, then:
read -rs GHCR_PAT # paste the token; it stays out of shell historykubectl -n gh-maintainer create secret docker-registry ghcr-pull \ --docker-server=ghcr.io --docker-username=<your-github-user> --docker-password="$GHCR_PAT"unset GHCR_PAT# Both workloads run as the namespace's default ServiceAccount:kubectl -n gh-maintainer patch serviceaccount default \ -p '{"imagePullSecrets":[{"name":"ghcr-pull"}]}'Build the images yourself
Section titled “Build the images yourself”To build locally instead, run scripts/build-images.sh --import from a clean, committed tree. It builds both images with docker, tags them with the git short SHA, rewrites newTag: in deploy/kustomization.yaml and imports the images into microk8s containerd. Then deploy the local root with kubectl apply -k deploy (it uses imagePullPolicy: Never). The local root is meant for development: it has the same CHANGE_ME and gh-maintainer.example.com placeholders as the base and no components, so the status server won’t start until the owner is set. For a real installation, use the GHCR images through your own overlay.
TLS and the private CA
Section titled “TLS and the private CA”The component deploy/components/private-ca sets up a small private CA with cert-manager, so clients trust the CA once and keep trusting renewed certificates. It needs cert-manager in the cluster. The example overlay enables it and patches the Certificate’s commonName and dnsNames to your host:
- ClusterIssuer
gh-maintainer-selfsignedbootstraps the CA. - Certificate
gh-maintainer-ca(namespacecert-manager, valid 10 years) is the CA. - ClusterIssuer
gh-maintainer-casigns with it. - Certificate
gh-maintainer-tlsis the leaf for the Ingress. cert-manager renews it automatically.
Check both certificates:
kubectl -n cert-manager get certificate gh-maintainer-ca # READY=Truekubectl -n gh-maintainer get certificate gh-maintainer-tls # READY=TrueWithout the component, the Ingress still expects its certificate in the Secret gh-maintainer-tls. Remove ../../components/private-ca and the Certificate patch from your overlay, then create that Secret yourself (kubectl -n gh-maintainer create secret tls gh-maintainer-tls --cert=... --key=...) or let your own issuer or ACME fill it. With a publicly trusted certificate you skip the CA trust step.
Overlays that use this component must not set a top-level namespace:: the CA Certificate lives in the namespace cert-manager.
Trust the private CA
Section titled “Trust the private CA”Install the CA once on every client: browsers, curl and the desktop app. On Debian/Ubuntu:
kubectl -n cert-manager get secret gh-maintainer-ca -o jsonpath='{.data.ca\.crt}' \ | base64 -d > /tmp/gh-maintainer-ca.crtopenssl x509 -in /tmp/gh-maintainer-ca.crt -noout -subject -enddate # CN = gh-maintainer CAsudo cp /tmp/gh-maintainer-ca.crt /usr/local/share/ca-certificates/gh-maintainer-ca.crtsudo update-ca-certificatescurl -s -o /dev/null -w '%{http_code}\n' https://gh-maintainer.example.com/state # 401, not a TLS errorrm /tmp/gh-maintainer-ca.crtBrowsers that keep their own store need an extra step:
- Firefox: Settings → Privacy & Security → Certificates → View Certificates → Authorities → Import, and tick “Trust this CA to identify websites”. Or set
security.enterprise_roots.enabled. - Chrome/Chromium on Linux:
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n gh-maintainer-ca -i <file>.
To remove the CA later, delete the file and run sudo update-ca-certificates --fresh.
Switch from dry run to live
Section titled “Switch from dry run to live”The base ConfigMap ships with dryRun: true, and stays that way: it is the safe default for every new installation. Run in dry run for about a week and review the feed every day (see Dry-run mode).
To go live, set dryRun: false in your overlay’s config.yaml and apply:
$EDITOR deploy/overlays/mine/config.yaml # dryRun: true -> dryRun: falsekubectl apply -k deploy/overlays/minekubectl -n gh-maintainer get configmap gh-maintainer-config \ -o jsonpath='{.data.config\.yaml}' | grep dryRunThe next job reads the new config; no restart is needed. From then on the agent really merges pull requests, pushes fixes to Dependabot branches, posts comments and deletes branches. To go back, set dryRun: true and apply again.
First-run checks
Section titled “First-run checks”Trigger a run and follow it:
kubectl -n gh-maintainer get pods,svc,ingress,pvc,certificate,cronjobkubectl -n gh-maintainer rollout status deployment/status-serverkubectl -n gh-maintainer create job --from=cronjob/gh-maintainer-agent e2e-1kubectl -n gh-maintainer logs -f job/e2e-1 -c agentA healthy job ends with gh-maintainer: run <runId> finished {...} and the status Completed. Then check:
-
The agent can read its secrets. A missing, empty or unreadable secret file, or a
401from GitHub, ends the job withstartup failedorrun failedand exit code 1:Terminal window kubectl -n gh-maintainer logs job/e2e-1 -c agent | grep -E 'startup failed|run failed' || echo "no startup errors" -
The data volume is writable by uid 10001. Hostpath provisioners ignore
fsGroup. If/datais not writable, the status server crash-loops on opening/data/state.db:Terminal window kubectl -n gh-maintainer exec deploy/status-server -- \node -e "require('fs').accessSync('/data', require('fs').constants.W_OK); console.log('writable')"# If not writable, fix the ownership on the node:PV=$(kubectl -n gh-maintainer get pvc status-server-data -o jsonpath='{.spec.volumeName}')DIR=$(kubectl get pv "$PV" -o jsonpath='{.spec.hostPath.path}')sudo chown 10001:10001 "$DIR"kubectl -n gh-maintainer rollout restart deployment/status-server -
The NetworkPolicy matches your ingress namespace, and other pods cannot reach the server:
Terminal window kubectl get pods -A | grep -Ei 'traefik|ingress' # the controller's namespacekubectl get networkpolicy -n gh-maintainer status-server-ingress -o yaml | grep -A6 namespaceSelectorkubectl -n gh-maintainer run np-test --rm -it --restart=Never --image=busybox:1.36 -- \wget -qO- -T 3 http://status-server:8080/healthz # expect a timeout -
The widget connects. The page loads, shows the last run, and the feed updates while a job runs:
Terminal window curl -sk -u <user> https://gh-maintainer.example.com/state | head -c 300; echocurl -sk -o /dev/null -w '%{http_code}\n' https://gh-maintainer.example.com/state # 401 without auth
Delete manual jobs when you are done: kubectl -n gh-maintainer delete job e2e-1. Each manual job needs a new name.
Only these paths are routed by the Ingress: /, /state, /info, /stream, /approve/*, /reject/* and /assets/*. Agent routes such as /events and /healthz are not reachable from outside.
Next steps
Section titled “Next steps”- Desktop app: the tray app for Linux, macOS and Windows.
- Operations: upgrades, backups, token rotation and pausing.
- Troubleshooting: common problems and fixes.