Skip to content
GitHub

Self-hostReference

Deployment

Holtkeeper runs as one image in every setting. A process gets its work from its role:

Terminal window
holtkeeper serve --role web|worker|scheduler|all # also HOLTKEEPER_ROLE; default all
Role HTTP Worker Scheduler duties (under the leader lease)
web API, UI, webhooks, probes, /metrics no no
worker probes and /metrics only yes no
scheduler probes and /metrics only no yes
all everything yes yes

Roles combine with commas: --role web,scheduler is the API plus the scheduler, which is what the Helm chart runs in its web pods by default.

Scheduler duties are the freshness sweep (the main source of automatic work), schedules, repository polling, webhook sync, the library index, credential rotation, artifact retention, audit retention, the daily storage snapshot (Settings › System’s 7-day change), the urgent vulnerability alerts and the daily audit chain check (GET /api/audit/verify/last). Every process with the scheduler role contends for a lease in the store (kv.acquireLease, key leader:scheduler, TTL 30 s, renewed every 10 s); only the holder runs the duties. When the holder dies, another process takes over within one TTL. When a renewal fails (store unreachable), the holder stops its duties at once, so two leaders do not overlap past one lease.

Worker flags:

Flag Environment Meaning
--concurrency <n> HOLTKEEPER_CONCURRENCY Jobs at once in this process (default jobs.concurrency)
--claim-delay <time> HOLTKEEPER_CLAIM_DELAY Take only jobs queued this long, e.g. 15s: workers without one go first
--pool <pools> HOLTKEEPER_WORKER_POOL Worker pools served, e.g. write, default,write (default default)
--max-jobs <n> HOLTKEEPER_MAX_JOBS Claim n jobs, finish them, exit 0: a fresh process or pod per job
--drain-timeout <time> HOLTKEEPER_DRAIN_TIMEOUT On SIGTERM, how long running jobs may finish (30s default, 2m, 500ms)

Before upgrading past the repo.readOnly retirement

Section titled “Before upgrading past the repo.readOnly retirement”

repo.readOnly is retired: stored entries are kept but no longer stop Holtkeeper from commenting, reviewing, opening merge requests or pushing. Before deploying, list them (GET /api/settings and look for repo.readOnly with value true, or the settings table) and set each one again as repo.freeze on the same scope. After the deploy, Settings › System shows a Read-only entries warning and the server logs one at start while any are left.

  • GET /healthz — 200 while the process answers.
  • GET /readyz — 200 when the store answers a query (stores migrate before their first answer; Postgres is also asked ready()), the artifact store answers a ping() (one cheap request, not a listing), and the process is not draining; 503 with a JSON body per check otherwise.
  • GET /metrics — Prometheus text format. Neither needs authentication; keep /metrics off public ingresses (the chart’s Ingress only routes to the web Service, but the path is served there too — block it at the ingress if the host is public).
  • SIGTERM: readiness fails at once, the worker stops claiming, running jobs get the drain timeout to finish and are then aborted and requeued to run again at once on another worker (the interrupted attempt counts), the leader lease is released, the store is closed. Give the container a grace period longer than the drain timeout.
Metric Type Source
holtkeeper_jobs_queued gauge store: queued jobs due now (the scaling signal)
holtkeeper_jobs{status="queued"|"running"} gauge store
holtkeeper_jobs_finished_total{analyzer,status} counter this process
holtkeeper_job_duration_seconds{analyzer} histogram this process (last attempt of each finished job)
holtkeeper_webhook_events_total{forge,status} counter this process
holtkeeper_ai_runs_total{provider,model} counter store (AI usage records)
holtkeeper_ai_tokens_total{provider,model,kind} counter store
holtkeeper_ai_cost_usd_total{provider,model} counter store
holtkeeper_limiter_saturated{key}, _in_flight, _queued gauge this process’s limiter (shared state when distributed)
holtkeeper_artifact_store_bytes, _objects gauge artifact store, listed at most every 5 minutes
holtkeeper_draining gauge this process

Store-backed series are reported only by processes with the API (web, all); every such process reports the same value, so aggregate them with max, not sum.

  • Postgres (@holtkeeper/store-postgres). SQLite is a local file; it works for one process (or several in one container sharing the file), not for pods on different nodes. For the statements, sessions and replica lag under Settings › System → Database (Slow queries and Sessions tabs), load pg_stat_statements and grant the Holtkeeper role pg_read_all_stats (rights); on CloudNativePG a pg_stat_statements.* parameter and a managed role with inRoles: [pg_read_all_stats] do it.
  • S3-compatible artifacts (server.artifacts: { kind: 's3', ... }: any S3-compatible storage — AWS S3, Cloudflare R2, Garage, Ceph, MinIO, Versity S3 Gateway — including one you already run). Workers write artifacts, web pods serve them. Settings › System › Storage shows the bucket (endpoint host, bucket, region), the bytes and objects under the prefix and server.retention. Optional server.artifacts.quotaBytes (the default config reads HOLTKEEPER_S3_QUOTA, in bytes) declares the space the bucket offers: the card then shows usage of that quota with a bar. Holtkeeper cannot measure a provider quota, so keep the figure in step with the real limit.
  • Distributed limits: limits: { distributed: true } keeps credential limiter counters in the store’s kv (compare-and-set), so several workers share one token’s rate and concurrency limits. Slots held by a process that dies are returned after 2 minutes without its heartbeat.
  • The same server.vaultKey everywhere.

Build the sandbox base, then the server image (multi-stage: bun install --frozen-lockfile, web UI build, runtime on the base with Bun and the workspace source — packages need no build):

Terminal window
docker build -t holtkeeper-worker:latest docker/worker
docker build -t holtkeeper:latest . # --build-arg BASE_IMAGE=... for another base

--build-arg HOLTKEEPER_VERSION=<tag or commit> bakes the release into the image as HOLTKEEPER_VERSION; the panel shows it in the Settings footer next to server.publicUrl (both come from GET /api/me). The release workflow passes the tag for v* tags and the commit otherwise; without it the footer shows no version.

The image runs as uid 10001, works with a read-only root filesystem (writable: /tmp, /data, /workspace, /mise), has a HEALTHCHECK on /healthz and the entrypoint holtkeeper serve. The config is mounted at /app/config/holtkeeper.config.ts (inside /app so its @holtkeeper/* imports resolve); deploy/holtkeeper.config.ts is a starting point that reads every secret from the environment and picks Postgres and S3 when their variables are set. Listen on 0.0.0.0 in containers.

holtkeeper.config.ts holds infrastructure only: server (auth, store, vaultKey, listener, publicUrl, artifacts, retention, the egress rules secret, credential rotation), jobs (execution with its egress proxy, concurrency, prioritySlots, cacheDir, timeoutMinutes, the shared webhookSecret), limits.distributed, ai.providers and dryRun. Everything else is set in the panel and stored in the database: forges (with their tokens as credentials, webhook secrets, bot username and fleet), teams, repository traits, schedules, triggers, merge request policies, analyzer options, the AI budget and the rest of the settings. A config file that still has forges, groups, teams, repos, plugins, jobs.schedules, jobs.on*, jobs.commands, jobs.botUsername or jobs.webhooks starts anyway: each such key gets one warning in the log and is ignored. Add the forge again in the panel and create teams on Repos › Teams (they replace groups). The job engine always runs, with defaults when the file has no jobs section.

Terminal window
docker run -d --name holtkeeper -p 7420:7420 --env-file .env --read-only --tmpfs /tmp \
-v "$PWD/holtkeeper.config.ts:/app/config/holtkeeper.config.ts:ro" \
-v holtkeeper-data:/data -v holtkeeper-workspace:/workspace -v holtkeeper-mise:/mise \
holtkeeper:latest -c /app/config/holtkeeper.config.ts --role all

SQLite and artifacts live in the /data volume; back it up (stop the container or use sqlite3 .backup).

deploy/docker-compose.yml: web (web,scheduler), worker (scale it), Postgres 17, and artifacts in S3: point S3_ENDPOINT, S3_BUCKET and the keys in .env at your existing S3-compatible storage, or start the bundled Versity S3 Gateway (posix backend in a volume) with docker compose --profile local-s3 up -d to try it without one. Secrets come from deploy/.env (template: deploy/.env.example), the config from deploy/holtkeeper.config.ts.

Terminal window
cd deploy && cp .env.example .env && $EDITOR .env
docker compose up -d --scale worker=3

The file has a commented single-container all service with SQLite for small installs. Add --max-jobs 1 to the worker command for a fresh container per job (restart: unless-stopped brings it back).

Jobs run inside the worker container in mise execution mode: the container is the sandbox, there is no container engine inside. container mode (one engine container per job, see docker/worker) needs the host’s Docker socket, which defeats the isolation — use it only for the single-host setup without compose.

The chart deploy/helm/holtkeeper renders:

  • a ConfigMap with holtkeeper.config.ts (config.content, default the chart’s files/holtkeeper.config.ts; or config.existingConfigMap), mounted read-only; pods restart when it changes. The default config has no forge: add the GitLab forge, its token credential and its fleet in the panel, then teams after the first sign-in (what the file holds);
  • HOLTKEEPER_VERSION in every container: version, else image.tag, else the chart’s appVersion, so the panel shows the release that runs;
  • existingSecret → environment of every container (HOLTKEEPER_VAULT_KEY, HOLTKEEPER_DATABASE_URL, HOLTKEEPER_S3_*, HOLTKEEPER_ROOT_PASSWORD, HOLTKEEPER_SESSION_SECRET, HOLTKEEPER_WEBHOOK_SECRET, …; forge tokens are credentials stored in the panel, not variables); env for plain values (HOLTKEEPER_AUTH=users switches the default config from the root password to accounts with passkeys: the first start logs the admin’s setup link, HOLTKEEPER_ADMIN_NAME/HOLTKEEPER_ADMIN_EMAIL name that admin, HOLTKEEPER_PUBLIC_URL is required; the config passes the store’s kv to usersAuth, which keeps pending invites and reads home teams for People; accounts for AI agents: Agent access);
  • web Deployment + Service (+ Ingress, + HPA on CPU, + PodDisruptionBudget), roles web,scheduler;
  • worker Deployment (replicas, concurrency, maxJobs, drainTimeout, resources) with a headless Service for metrics, PDB; or, with worker.pools, one Deployment per pool (<release>-worker-<name>, label holtkeeper.dev/worker-pool), each worker with the pool’s own fields on top, e.g. 2 jobs per small node and 4 on a big one; claimDelay: 15s makes a pool take only jobs no other pool claimed within that time, so the pools without one fill first; spread: true keeps a pool’s pods on different nodes, counting only the current ReplicaSet so pods of a finishing rollout do not push two onto one node; strategy sets the Deployment update strategy of worker or one pool, e.g. { rollingUpdate: { maxSurge: 0, maxUnavailable: 1 } } for a pool pinned to a node without room for a second pod, whose default surge pod would otherwise wait for the CPU the old pod holds;
  • optional scheduler Deployment (scheduler.enabled; the web pods then run web only);
  • optional write worker Deployment (writeWorker.enabled, see Write workers);
  • optional ServiceMonitor, KEDA ScaledObject or ScaledJob, NetworkPolicies;
  • optional egress proxy (egressProxy.enabled, see below) with a download cache;
  • a ServiceAccount without any Role: nothing talks to the Kubernetes API and no pod-creation rights are needed. Tokens are not mounted.

Every pod runs non-root (10001) with readOnlyRootFilesystem, no capabilities, RuntimeDefault seccomp; /tmp (also HOME, so bun, npm and Go caches of dependency installs; tmpSizeLimit, default 8Gi), /workspace (checkouts, mirror cache) and /mise (tools) are emptyDirs, /mise optionally a PVC (worker.miseCache.type: pvc, ReadWriteMany to share between workers). The git mirror cache can move to its own PVC (worker.mirrorCache.type: pvc, default 50Gi ReadWriteMany): mirrors then survive restarts and deploys instead of being cloned again by every new pod, and workers share them, taking a lock file per mirror (NFS works). Pods set fsGroupChangePolicy: OnRootMismatch, so such volumes are not re-owned file by file on every start. Workers report what their mirror and tool caches use to the store, and Settings › System → Storage shows it per worker (a shared volume once). Probes: startup and liveness on /healthz, readiness on /readyz.

Terminal window
kubectl create secret generic holtkeeper --from-env-file=holtkeeper.env
helm install holtkeeper deploy/helm/holtkeeper --set existingSecret=holtkeeper \
--set image.repository=registry.example.com/holtkeeper --set image.tag=1.0.0 \
--set web.ingress.enabled=true --set 'web.ingress.hosts[0].host=holtkeeper.example.com' \
--set 'web.ingress.hosts[0].paths[0]=/'

values.schema.json validates the values; ci/*.yaml are the files the chart is linted and rendered with.

  • Web: stateless; scale with web.replicas or web.hpa. Only one web pod runs the scheduler at a time (lease).
  • Workers: worker.replicas × concurrency (summed over worker.pools) is the job parallelism. A worker hands a free slot to the job it claimed first among those its credential limits admit, so a long-waiting job is not starved by a stream of short ones. Merge request reviews skip the queue: they are claimed before every other job, ignore claimDelay, and each worker keeps jobs.prioritySlots (default 1) express slots only they take while its regular slots are busy, so a pod may briefly run concurrency + prioritySlots jobs. With keda.enabled a ScaledObject scales the worker Deployment on max(holtkeeper_jobs_queued) from Prometheus (keda.threshold queued jobs per replica). The queue runs at most one job per analyzer and repository at a time; jobs of analyzers that change repositories (propagate) run alone on their repository or team. Other analyzers of one repository run side by side, so more workers help until every repository runs one job per queued analyzer.
  • Limits: set limits.distributed: true (the default config does when Postgres is used) so forge and AI tokens are rate-limited across all workers, not per pod.

Jobs run analyzers (and repository tooling via mise) inside the worker pod. For untrusted repositories give every job a fresh pod:

  • keda.scaledJob.enabled: true (with keda.enabled): a KEDA ScaledJob creates one Kubernetes Job per queued job; its pod runs --max-jobs 1, exits 0, and is never reused (restartPolicy: Never, backoffLimit: 0; a pod that dies mid-job is recovered by the queue’s heartbeat timeout and retried on a new pod). activeDeadlineSeconds bounds a pod that found no job.
  • Without KEDA, worker.maxJobs: 1 restarts the container after each job. The emptyDirs survive container restarts (the job removes its checkout, the tool cache is kept), and kubelet backs off repeated restarts, so this is weaker and slower than ScaledJob.

Job commands do not inherit the worker’s secrets: in mise mode they start from an allowlist of the worker’s variables (paths, locale, MISE_*, proxies; extend it with jobs.execution.envAllowlist), and nothing named HOLTKEEPER_*, GITLAB_TOKEN or the like reaches them. That stops accidental leaks (a test runner dumping its environment, a dependency reading process.env), not a command written to steal them. What remains, because commands run as the worker’s uid (10001) in its container:

  • /proc/<worker pid>/environ is readable by the same uid and still holds every variable of existingSecret. shareProcessNamespace is off, which only separates containers of a pod, not processes in one container. hidepid does not help: Kubernetes cannot set /proc mount options (procMount is Default or Unmasked), and hidepid hides other uids’ processes anyway. A separate uid for jobs inside the container would need setuid, which allowPrivilegeEscalation: false and dropped capabilities forbid.
  • The config file, other jobs’ checkouts in /workspace and every destination the worker’s NetworkPolicy allows (Postgres, object store) are reachable too.
  • keda.scaledJob narrows this to one job per pod (no other checkouts, nothing survives the job), but that pod still gets existingSecret, because the worker needs the database and the vault key.

Closing the gap needs the commands out of the worker’s process tree, which the chart does not do yet: run them in a sidecar container of the worker pod with its own uid, no envFrom and only /workspace and /mise shared (pods keep separate PID namespaces per container), or mark the worker process non-dumpable (prctl(PR_SET_DUMPABLE, 0) makes its /proc files root-owned). Until then, analyze only repositories whose code you would let run with the worker’s credentials, or use ScaledJob plus NetworkPolicies to limit what a stolen credential reaches.

Combine with networkPolicy.enabled: worker and scheduler pods accept only metrics scrapes (metricsFrom) and reach only DNS, workerEgress ports (443/80/22 — forge, package registries, LLM APIs) and extraEgress (Postgres, object store); web pods accept traffic only from webIngressFrom (the ingress controller).

Write tasks (@holtkeeper/write-task) let an agent edit a checkout, run the repository’s checks, push a branch and open a draft merge request. Only workers of the write pool claim them, so they never run on the regular workers. writeWorker.enabled (off by default, needs egressProxy.enabled) adds that pool:

writeWorker:
enabled: true
replicas: 1
concurrency: 1
resources:
requests: { cpu: 500m, memory: 1Gi }
limits: { cpu: '1', memory: 2Gi }
egressProxy:
enabled: true
networkPolicy:
enabled: true
extraEgress: [] # Postgres and the object store, as for the other workers
  • A Deployment <release>-write-worker (component write-worker, label holtkeeper.dev/worker-pool: write) running --role worker --pool write; fields it does not set come from worker (drain timeout, volumes, caches). No KEDA scaling and no Service; it is not part of worker.pools.
  • The process gets HTTP_PROXY/HTTPS_PROXY (lower case too) pointing at the egress proxy, NO_PROXY with in-cluster names, egressProxy.noProxy and writeWorker.noProxy, and the proxy CA: NODE_EXTRA_CA_CERTS for Node and Bun, and a bundle of the system store plus the CA (SSL_CERT_FILE, GIT_SSL_CAINFO, CURL_CA_BUNDLE, built by an init container) for git and other clients, since the proxy intercepts TLS to rule hosts such as the forge. Forge API calls, git over HTTPS, LLM requests, the agent’s commands and package installs all go through the proxy, which adds the registry tokens it holds; nothing new is stored in the pod.
  • With networkPolicy.enabled a NetworkPolicy lets the pods reach only DNS, the egress proxy, networkPolicy.extraEgress (database, object store) and writeWorker.extraEgress, and accept only metrics scrapes. Git over SSH needs port 22 to the forge in writeWorker.extraEgress; without it use HTTPS clones. The egress proxy’s own NetworkPolicy then also accepts the write workers.
  • Write tasks stay refused until an admin turns on the tasks.write setting (Ops › Tasks). People approve them in Ops › Tasks, from chat task cards, the Roll out button of Supply › Libraries, or POST /api/task-groups (MCP has no tool that starts tasks), and need tasks:run on every repository; read-only repositories (a repo.freeze in force) are refused when the task is queued and again when it starts.
  • Write workers refuse to start, and write tasks refuse to run, while jobs.execution.mode is host (the default): checks run repository scripts the agent may edit, so they need the mise or container sandbox. Holtkeeper’s own git ignores hooks and core.fsmonitor from the shared mirror, but a script can still rewrite the mirror’s other config; container mode isolates it best.
  • Caveat: the agent’s commands run as the worker’s uid, like every job command, so the /proc limits under Isolation apply. Keep writeWorker.replicas × concurrency small and the pool’s secrets to what the worker needs.

egressProxy.enabled deploys docker/egress-proxy: a forward proxy that adds credentials to package registry requests of jobs, so jobs install private packages without ever holding a token. Workers get HOLTKEEPER_EGRESS_PROXY, HOLTKEEPER_EGRESS_CA (the CA certificate only, never its key) and HOLTKEEPER_EGRESS_NO_PROXY; the bundled config turns them into jobs.execution.egress. Holtkeeper’s own traffic (forge API, database, object store) does not go through it.

existingSecret: holtkeeper # with HOLTKEEPER_EGRESS_SECRET=<random string> among the other keys
egressProxy:
enabled: true
ca:
certManager: true # or existingSecret: a kubernetes.io/tls Secret with the CA

With forgeRules (the default) the proxy reads its rules from the web pods (GET /api/egress/rules, authenticated with HOLTKEEPER_EGRESS_SECRET from the top-level existingSecret, which the bundled config also turns into server.egress). Every panel GitLab forge then has its token, the same credential the forge uses, added to downloads from its package registries, always the current one after a rotation; the forge’s Packages for jobs switch turns that off. The same switch also adds read-only git rules for the forge (go get discovery, info/refs and git-upload-pack, never git-receive-pack), and workers give jobs GOPRIVATE (the forge host or its top-level groups, joined with every private Go module pattern of the instance, which jobs get even without an egress proxy) and GOTOOLCHAIN=local, so go downloads private modules of the forge through the proxy without the token entering the job. Trade-off: through the proxy, every job can read every repository the forge token can read, over git. Give the forge a token scoped to what the fleet needs. Static rules can be added for other registries:

egressProxy:
existingSecret: holtkeeper-egress # REGISTRY_TOKEN=...
rules:
- host: registry.example.com
paths: ['^/npm/']
headers:
Authorization: 'Bearer ${REGISTRY_TOKEN}'

${NAME} in static rules is resolved by the proxy from egressProxy.existingSecret, not by Helm. Only GET/HEAD get credentials unless a rule lists methods, and only over TLS unless it sets insecure. TLS to hosts without rules is tunneled untouched. The pod restarts when static rules change; restart it after changing a static token or the CA. With networkPolicy.enabled the proxy accepts only workers, reaches the web pods for its rules, and workers may reach it.

To use another proxy, leave egressProxy disabled and set HOLTKEEPER_EGRESS_PROXY (and HOLTKEEPER_EGRESS_CA) on the workers yourself.

egressProxy.cache (on by default) keeps package archives (npm and yarn tarballs, Go modules, PyPI files, crates) and tool downloads (Node.js, Go, GitHub release assets, which mise uses for most tools) that jobs fetch through the proxy. They then come from the cache instead of the internet, and pods that start empty, such as emptyDir worker caches, do not slow down. Only immutable archives are cached; indexes and version lists always go upstream. A broken store never breaks an install: the request then goes upstream. What is cached and how is in docker/egress-proxy.

egressProxy:
cache:
ttl: { packages: 28d, tools: 21d } # since the last use
maxSize: 18Gi # least recently used first above this; keep it below the volume
backend: dir # an emptyDir (dir.sizeLimit, default 20Gi) or dir.type: pvc
# backend: s3 — one bucket for every replica:
# s3: { bucket: holtkeeper, endpoint: https://s3.example.com, region: eu-north-1,
# prefix: egress-cache, existingSecret: holtkeeper-s3 } # AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY

A dir store on an emptyDir is lost when the proxy pod is replaced, and each replica has its own. For replicas above 1 use s3 or a ReadWriteMany pvc. S3 downloads are spooled to an emptyDir (s3.spoolSizeLimit) until complete. cache.rules adds cacheable URLs ({ kind, host, paths, private }); enabled: false sets EGRESS_CACHE=off.

The Caches section of the panel (Settings › System, global settings:read) shows what is cached, its size, hits and expiry, and removes entries (global settings:write). The web pods reach the proxy for it (HOLTKEEPER_EGRESS_CACHE, turned into server.egress.proxy) with HOLTKEEPER_EGRESS_SECRET, so the page needs the top-level existingSecret with that key. With networkPolicy.enabled the proxy then also accepts the web pods.

[!WARNING] A cached download is served to every job until it expires, whoever fetched it and whatever changed since. A version unpublished or yanked upstream (for example a malicious one taken down), or a GitHub asset replaced under the same tag, is still served. With Cache packages on a panel forge (off by default) or private cache rules, packages fetched with a forge token stay available after the token is revoked, the forge’s Packages for jobs is switched off, or the project’s access changes, and every job can read what another job’s credentials fetched. Keep private rules off unless every job may see every such package. Remove entries in Settings › System → Caches when something has to go at once. Give only the proxy write access to the cache volume or bucket: whoever can write it can serve any file under a cached URL.

Forges post to https://<host>/api/webhooks/<forge>. Set HOLTKEEPER_PUBLIC_URL (server.publicUrl) so the URLs Holtkeeper registers point at the Ingress host, keep the webhook secret in the Secret, allow request bodies of a few MB (nginx.ingress.kubernetes.io/proxy-body-size), and let the forge’s egress addresses through webIngressFrom when NetworkPolicies are on. Any web pod can take a webhook: it only enqueues jobs in the shared store.

  • Postgres: regular pg_dump (or your operator’s backups / PITR) of the holtkeeper schema. It holds everything except artifacts; credentials and secret settings in it are sealed with the vault key.
  • Artifacts: S3 bucket versioning or replication; artifacts are content-addressed and can be regenerated by rerunning analyses, so this is optional.
  • The vault key and the Secret: store them outside the cluster (password manager, KMS). Without the vault key the sealed credentials in a backup cannot be read.
  • /mise and /workspace are caches; never back them up.