Skip to content

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.

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:

Terminal window
kubectl get ingressclass # look for ingressclass.kubernetes.io/is-default-class
kubectl 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:

Terminal window
microk8s enable dns ingress cert-manager hostpath-storage
microk8s status --wait-ready
kubectl get ingressclass,storageclass
kubectl -n cert-manager get pods

Check that NetworkPolicy is enforced. With Calico, this lists running pods:

Terminal window
kubectl -n kube-system get pods -l k8s-app=calico-node

You 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.

  • kubectl (with built-in kustomize)
  • htpasswd (Debian/Ubuntu: apache2-utils) for the basic-auth file
  • openssl for the event token
  • the claude CLI, for claude setup-token
  • docker, only if you build the images yourself

gh-maintainer needs three tokens in the Secret gh-maintainer, plus a basic-auth secret for the ingress.

Create the token at GitHub → Settings → Developer settings → Fine-grained tokens:

  • Resource owner: the user or organization gh-maintainer maintains (the owner in 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:

Terminal window
claude setup-token # prints a long-lived OAuth token for your subscription

The agent uses this bearer token to POST events to the status server:

Terminal window
openssl rand -hex 32

The namespace must exist first:

Terminal window
kubectl apply -f deploy/base/namespace.yaml
cp deploy/secret.example.yaml deploy/secret.yaml
chmod 600 deploy/secret.yaml # before any real value goes in
$EDITOR deploy/secret.yaml # replace the three REPLACE_ME_* values
kubectl apply -f deploy/secret.yaml
shred -u deploy/secret.yaml 2>/dev/null || rm -f deploy/secret.yaml

Check the keys without printing the values:

Terminal window
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_TOKEN

The 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.

The widget and the approve/reject routes sit behind HTTP basic auth at the ingress. Create an htpasswd file with bcrypt hashes:

Terminal window
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 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.

Terminal window
kubectl -n gh-maintainer create secret generic gh-maintainer-auth \
--from-file=auth=deploy/auth.htpasswd

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@kubernetescrd
  • traefik.ingress.kubernetes.io/router.entrypoints: websecure
  • traefik.ingress.kubernetes.io/router.tls: "true"

The Middleware reads the Secret gh-maintainer-traefik-auth, which must contain exactly one key, users:

Terminal window
kubectl -n gh-maintainer create secret generic gh-maintainer-traefik-auth \
--from-file=users=deploy/auth.htpasswd

After deploying, check that auth is enforced. Without credentials you must get 401:

Terminal window
curl -sk -o /dev/null -w '%{http_code}\n' https://gh-maintainer.example.com/state

Use a dedicated htpasswd user for the desktop app, because the app stores its password in plain text.

The Release workflow pushes two linux/amd64 images:

  • ghcr.io/pierrejochem/gh-maintainer-agent
  • ghcr.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.

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:

Terminal window
cp -r deploy/overlays/example deploy/overlays/mine
$EDITOR deploy/overlays/mine/kustomization.yaml deploy/overlays/mine/config.yaml
kubectl kustomize deploy/overlays/mine | grep -E 'image:|host:|owner:|OWNER' -A1 # review
kubectl apply -k deploy/overlays/mine

Create the secrets before the first apply.

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 organization

The test makes the render fail if a future base moves OWNER away from the second environment variable, instead of silently overwriting another variable.

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.

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/ingressClassName in the Ingress patch, such as traefik, nginx or public on microk8s.
  • StorageClass: if your cluster has no default StorageClass, add /spec/storageClassName to the status-server-data PersistentVolumeClaim, such as local-path or microk8s-hostpath.
  • NetworkPolicy: the base admits the ingress namespaces ingress, ingress-nginx, traefik and kube-system. To allow only your controller’s namespace, replace the namespaceSelector of status-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-nginx

The 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.

Every vX.Y.Z GitHub release carries the rendered manifests for that version, built from deploy/overlays/ghcr:

Terminal window
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.

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:

Terminal window
read -rs GHCR_PAT # paste the token; it stays out of shell history
kubectl -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"}]}'

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.

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:

  1. ClusterIssuer gh-maintainer-selfsigned bootstraps the CA.
  2. Certificate gh-maintainer-ca (namespace cert-manager, valid 10 years) is the CA.
  3. ClusterIssuer gh-maintainer-ca signs with it.
  4. Certificate gh-maintainer-tls is the leaf for the Ingress. cert-manager renews it automatically.

Check both certificates:

Terminal window
kubectl -n cert-manager get certificate gh-maintainer-ca # READY=True
kubectl -n gh-maintainer get certificate gh-maintainer-tls # READY=True

Without 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.

Install the CA once on every client: browsers, curl and the desktop app. On Debian/Ubuntu:

Terminal window
kubectl -n cert-manager get secret gh-maintainer-ca -o jsonpath='{.data.ca\.crt}' \
| base64 -d > /tmp/gh-maintainer-ca.crt
openssl x509 -in /tmp/gh-maintainer-ca.crt -noout -subject -enddate # CN = gh-maintainer CA
sudo cp /tmp/gh-maintainer-ca.crt /usr/local/share/ca-certificates/gh-maintainer-ca.crt
sudo update-ca-certificates
curl -s -o /dev/null -w '%{http_code}\n' https://gh-maintainer.example.com/state # 401, not a TLS error
rm /tmp/gh-maintainer-ca.crt

Browsers 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.

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:

Terminal window
$EDITOR deploy/overlays/mine/config.yaml # dryRun: true -> dryRun: false
kubectl apply -k deploy/overlays/mine
kubectl -n gh-maintainer get configmap gh-maintainer-config \
-o jsonpath='{.data.config\.yaml}' | grep dryRun

The 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.

Trigger a run and follow it:

Terminal window
kubectl -n gh-maintainer get pods,svc,ingress,pvc,certificate,cronjob
kubectl -n gh-maintainer rollout status deployment/status-server
kubectl -n gh-maintainer create job --from=cronjob/gh-maintainer-agent e2e-1
kubectl -n gh-maintainer logs -f job/e2e-1 -c agent

A healthy job ends with gh-maintainer: run <runId> finished {...} and the status Completed. Then check:

  1. The agent can read its secrets. A missing, empty or unreadable secret file, or a 401 from GitHub, ends the job with startup failed or run failed and 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"
  2. The data volume is writable by uid 10001. Hostpath provisioners ignore fsGroup. If /data is 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
  3. 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 namespace
    kubectl get networkpolicy -n gh-maintainer status-server-ingress -o yaml | grep -A6 namespaceSelector
    kubectl -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
  4. 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; echo
    curl -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.