Skip to content

Operations

Day-to-day tasks for a running gh-maintainer installation. All commands assume the namespace gh-maintainer and the default object names:

Object Name
CronJob gh-maintainer-agent
Deployment and Service status-server
PersistentVolumeClaim status-server-data
ConfigMap gh-maintainer-config
Secrets gh-maintainer, gh-maintainer-auth, gh-maintainer-traefik-auth

The CronJob runs at minute 0 of every second hour. To start a run immediately:

Terminal window
kubectl -n gh-maintainer create job --from=cronjob/gh-maintainer-agent manual-1
kubectl -n gh-maintainer get job manual-1 -w

Each manual job needs a new name (manual-2, …). Delete it when you are done:

Terminal window
kubectl -n gh-maintainer delete job manual-1

The CronJob uses concurrencyPolicy: Forbid, so a scheduled run does not start while another scheduled run is still active. A scheduled run that was missed by more than an hour (node down, controller restart) is skipped; the next slot picks up the work.

Terminal window
kubectl -n gh-maintainer get jobs # the CronJob keeps the last 3 ok / 3 failed jobs
kubectl -n gh-maintainer logs -f job/<job-name> -c agent # the agent's log
kubectl -n gh-maintainer logs deployment/status-server # JSON request log, prune messages

A healthy job ends with gh-maintainer: run <runId> finished {...}.

The agent POSTs events to the status server in chunks of at most 500 and retries 3 times (after 1 s, 2 s and 4 s) on network errors, timeouts, 5xx, 408 and 429. If the server is still unreachable, or answers with any other 4xx (for example 401 for a wrong EVENT_TOKEN), the agent writes each event to its log as one JSON line and drops it. Maintenance continues regardless.

Those events exist only in the job log. Extract them with jq:

Terminal window
kubectl -n gh-maintainer logs job/<job-name> -c agent | grep '^{' | jq -c '{type, repo, data}'

The widget’s data is available as JSON at /state, behind basic auth:

Terminal window
curl -s -u <user> https://gh-maintainer.example.com/state | jq '{run, dryRun, approvals: (.approvals | length), findings: (.findings | length)}'

See the events reference for the full snapshot format.

Each real deletion emits branch.deleted with name, sha and reason. Find it in the widget feed, or in the last 100 events of /state:

Terminal window
curl -s -u <user> https://gh-maintainer.example.com/state \
| jq '.recentEvents[] | select(.type=="branch.deleted") | {repo, data}'

Then, in a clone of that repository:

Terminal window
git fetch origin <sha> # if the commit is not in your clone
git push origin <sha>:refs/heads/<name>

GitHub keeps unreferenced commits for a while, but not forever, so restore soon after the deletion.

Read the changelog for the new version first. Then change both newTag values in your overlay to the new release version (for example "1.3.0"), or to the sha-<short> tag the Release workflow pushed for a specific commit:

images:
- name: ghcr.io/pierrejochem/gh-maintainer-agent
newTag: sha-<short>
- name: ghcr.io/pierrejochem/gh-maintainer-status-server
newTag: sha-<short>

Then render, check and apply:

Terminal window
kubectl kustomize deploy/overlays/mine | grep image:
kubectl apply -k deploy/overlays/mine
kubectl -n gh-maintainer rollout status deployment/status-server

The next agent job uses the new agent image automatically.

Terminal window
gh release download v1.3.0 -R pierrejochem/gh-maintainer -p 'gh-maintainer-1.3.0.yaml'
kubectl apply -f gh-maintainer-1.3.0.yaml

The release manifest contains the base placeholders (owner: CHANGE_ME, OWNER=CHANGE_ME, host gh-maintainer.example.com, dryRun: true) and no Traefik or private CA component. Applying it unedited resets your settings, and the status server and the agent refuse to start until the owner is set again. Edit the file before applying it, or upgrade with a pinned overlay instead.

The status server uses the Recreate strategy, because SQLite lives on a ReadWriteOnce volume and two pods must never run at once. The old pod stops before the new one starts, so for a few seconds:

  • the widget shows offline · reconnecting, and the ingress may answer 503;
  • the desktop tray icon turns grey.

Both reconnect on their own once the new pod is ready. An agent run during that window keeps working and falls back to logging events to stdout.

All history lives in one SQLite file, /data/state.db, on the PVC status-server-data: events (30 days), runs, repositories, findings, approvals, fix attempts and scan times. On a hostpath volume, it lives on one node’s disk.

Make a consistent online copy with SQLite’s backup API inside the running pod, then copy it out:

Terminal window
kubectl -n gh-maintainer exec deploy/status-server -- node -e \
"new (require('better-sqlite3'))('/data/state.db').backup('/data/state-backup.db').then(() => console.log('ok'))"
kubectl -n gh-maintainer exec deploy/status-server -- cat /data/state-backup.db > state-backup.db
kubectl -n gh-maintainer exec deploy/status-server -- rm /data/state-backup.db

The database runs in WAL mode, so copying only state.db from the volume while the server runs can miss recent writes. Use the backup API, or stop the server first.

If you lose the database, gh-maintainer still works: the next run rebuilds repositories, findings and open approvals. You lose the event history, rejected approvals (they come back as open) and the fix-attempt cooldowns.

  1. Recreate deploy/secret.yaml from the template, with chmod 600 before any real value goes in.

  2. Apply it and delete the file again:

    Terminal window
    kubectl apply -f deploy/secret.yaml
    shred -u deploy/secret.yaml 2>/dev/null || rm -f deploy/secret.yaml
  3. Restart the status server, which reads EVENT_TOKEN and GITHUB_TOKEN from its environment at start:

    Terminal window
    kubectl -n gh-maintainer rollout restart deployment/status-server

The next agent job reads the new secret files by itself.

To change the widget password, recreate the htpasswd file and replace the basic-auth secret of your ingress controller (gh-maintainer-auth for ingress-nginx, gh-maintainer-traefik-auth for the Traefik component):

Terminal window
htpasswd -cB deploy/auth.htpasswd <user>
kubectl -n gh-maintainer create secret generic gh-maintainer-auth \
--from-file=auth=deploy/auth.htpasswd --dry-run=client -o yaml | kubectl apply -f -
kubectl -n gh-maintainer create secret generic gh-maintainer-traefik-auth \
--from-file=users=deploy/auth.htpasswd --dry-run=client -o yaml | kubectl apply -f -

Update the URL in the desktop app with Change server… afterwards.

Suspend the CronJob to stop new runs:

Terminal window
kubectl -n gh-maintainer patch cronjob gh-maintainer-agent -p '{"spec":{"suspend":true}}'

To also stop a run in progress, delete its job:

Terminal window
kubectl -n gh-maintainer get jobs
kubectl -n gh-maintainer delete job <job-name>

Resume:

Terminal window
kubectl -n gh-maintainer patch cronjob gh-maintainer-agent -p '{"spec":{"suspend":false}}'

The widget and the approval queue keep working while the CronJob is suspended. A deleted job never sends run.finished, so the widget keeps showing that run as running until the next run starts and marks it aborted.

Edit config.yaml in your overlay and apply it. The next job reads the new config; no restart is needed:

Terminal window
kubectl apply -k deploy/overlays/mine
kubectl -n gh-maintainer get configmap gh-maintainer-config -o jsonpath='{.data.config\.yaml}'

An invalid config makes the next job fail with gh-maintainer: startup failed: .... See the configuration reference.

Local scans (trivy, gitleaks, osv-scanner) run at most once every security.localScanIntervalHours per repository. There is no command to reset that timer. To rescan sooner, lower security.localScanIntervalHours in your config, trigger a run, then set it back.

The status server deletes events older than 30 days, once at start and then daily. Runs, repositories, findings and approvals are kept.