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 |
Trigger a run now
Section titled “Trigger a run now”The CronJob runs at minute 0 of every second hour. To start a run immediately:
kubectl -n gh-maintainer create job --from=cronjob/gh-maintainer-agent manual-1kubectl -n gh-maintainer get job manual-1 -wEach manual job needs a new name (manual-2, …). Delete it when you are done:
kubectl -n gh-maintainer delete job manual-1The 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.
Read the logs
Section titled “Read the logs”kubectl -n gh-maintainer get jobs # the CronJob keeps the last 3 ok / 3 failed jobskubectl -n gh-maintainer logs -f job/<job-name> -c agent # the agent's logkubectl -n gh-maintainer logs deployment/status-server # JSON request log, prune messagesA healthy job ends with gh-maintainer: run <runId> finished {...}.
The stdout fallback
Section titled “The stdout fallback”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:
kubectl -n gh-maintainer logs job/<job-name> -c agent | grep '^{' | jq -c '{type, repo, data}'Query the current state
Section titled “Query the current state”The widget’s data is available as JSON at /state, behind basic auth:
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.
Restore a deleted branch
Section titled “Restore a deleted branch”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:
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:
git fetch origin <sha> # if the commit is not in your clonegit push origin <sha>:refs/heads/<name>GitHub keeps unreferenced commits for a while, but not forever, so restore soon after the deletion.
Upgrade
Section titled “Upgrade”With a pinned overlay
Section titled “With a pinned overlay”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:
kubectl kustomize deploy/overlays/mine | grep image:kubectl apply -k deploy/overlays/minekubectl -n gh-maintainer rollout status deployment/status-serverThe next agent job uses the new agent image automatically.
With a release manifest
Section titled “With a release manifest”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.yamlThe 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.
What to expect during a rollout
Section titled “What to expect during a rollout”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.
Back up the database
Section titled “Back up the database”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:
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.dbkubectl -n gh-maintainer exec deploy/status-server -- rm /data/state-backup.dbThe 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.
Rotate tokens
Section titled “Rotate tokens”-
Recreate
deploy/secret.yamlfrom the template, withchmod 600before any real value goes in. -
Apply it and delete the file again:
Terminal window kubectl apply -f deploy/secret.yamlshred -u deploy/secret.yaml 2>/dev/null || rm -f deploy/secret.yaml -
Restart the status server, which reads
EVENT_TOKENandGITHUB_TOKENfrom 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):
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.
Pause and resume
Section titled “Pause and resume”Suspend the CronJob to stop new runs:
kubectl -n gh-maintainer patch cronjob gh-maintainer-agent -p '{"spec":{"suspend":true}}'To also stop a run in progress, delete its job:
kubectl -n gh-maintainer get jobskubectl -n gh-maintainer delete job <job-name>Resume:
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.
Change the configuration
Section titled “Change the configuration”Edit config.yaml in your overlay and apply it. The next job reads the new config; no restart is needed:
kubectl apply -k deploy/overlays/minekubectl -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.
Force a local rescan
Section titled “Force a local rescan”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.
Event retention
Section titled “Event retention”The status server deletes events older than 30 days, once at start and then daily. Runs, repositories, findings and approvals are kept.