Skip to content

Installing

Kelpie runs as a stack on a Docker Swarm: the server on a manager, an agent on every node, and Postgres. The example stack file puts it behind Traefik.

  • A Docker Swarm to run Kelpie itself. A single-node Swarm (docker swarm init) is fine, and the stacks you deploy can still be plain Compose projects.
  • A reverse proxy that terminates TLS and passes WebSocket upgrades. Logs, terminals, and live updates use WebSockets.
  • A directory on a manager for the database and git checkouts.
  • openssl on the manager, to generate the agent token and the database password.

Kelpie reads its keys and the database URL from Swarm secrets, so they stay out of the service definition. Generate the two keys first, and keep copies of these files outside the cluster (see Keys and backups):

Terminal window
docker run --rm ghcr.io/denniedev/kelpie:0.2.10 generate-key > secret-key
docker run --rm ghcr.io/denniedev/kelpie:0.2.10 generate-age-key > age-key

age-key holds the private key (the AGE-SECRET-KEY-... line) and, in a comment, its public key. The public key goes in your repositories’ .sops.yaml (see Variables and secrets).

Then create the secrets on a manager:

Terminal window
docker secret create kelpie_secret_key secret-key
grep '^AGE-SECRET-KEY' age-key | docker secret create kelpie_age_key -
openssl rand -hex 32 | docker secret create kelpie_agent_token -
password=$(openssl rand -hex 24)
printf '%s' "$password" | docker secret create kelpie_postgres_password -
printf 'postgresql+asyncpg://kelpie:%s@postgres:5432/kelpie' "$password" \
| docker secret create kelpie_database_url -

The database password is in two secrets: Postgres reads it on its own, Kelpie as part of the URL. Postgres only reads it when it creates the database.

Download docker-compose.yml and set your own values under the server’s environment: and in the Traefik router rule. Create the data directories and deploy from the directory with the file:

Terminal window
mkdir -p /data/kelpie/data /data/kelpie/postgres
export KELPIE_IMAGE=ghcr.io/denniedev/kelpie:0.2.10
docker stack deploy -c docker-compose.yml kelpie

Pin a version rather than latest, so a redeploy never upgrades by accident.

Once the server runs, create the first admin on the manager that runs it:

Terminal window
docker exec -it "$(docker ps -q -f name=kelpie_server)" kelpie create-admin

Then log in as admin and continue with Your first stack.

The stack file has labels for Traefik’s swarm provider (Traefik v3). Change the host in the router rule to your own. Keep traefik.swarm.lbswarm=true: without it, Traefik routes to the new server before it is ready, and every upgrade answers 502 for a few seconds. Traefik reaches Kelpie over the traefik network, which has to be an attachable overlay:

Terminal window
docker network create -d overlay --attachable traefik

Compose containers can join that network too.

Drop the Traefik labels and the traefik network from the stack file. Kelpie listens on port 8000 without TLS; point the proxy at that, with WebSocket upgrades enabled.

  • KELPIE_PUBLIC_URL: the external address, such as https://kelpie.example.com. Used for OIDC redirect URIs and edge agent keys.
  • KELPIE_TRUSTED_PROXIES: the proxy’s address or network, so client IPs in the audit log come from X-Forwarded-For. Swarm overlay networks use 10.0.0.0/8 unless the Swarm was set up with another address pool.

The audit log and the API token list record the address each request came from. Kelpie reads X-Forwarded-For from right to left and takes the first address that isn’t in KELPIE_TRUSTED_PROXIES, so every proxy between the client and Kelpie has to be listed there. If the log shows your proxy’s or CDN’s addresses instead of your users’, a hop is missing.

Behind Cloudflare or another CDN in front of Traefik, two settings are needed:

  • Traefik has to trust the CDN, or it replaces the CDN’s X-Forwarded-For with its own. On the entrypoint, list the CDN’s ranges under forwardedHeaders.trustedIPs; Cloudflare publishes them at cloudflare.com/ips.
  • Kelpie has to trust both: add the same ranges to KELPIE_TRUSTED_PROXIES after the traefik network, comma-separated.

Without a proxy, a port published through Swarm’s routing mesh hides the client: requests arrive from the ingress network’s address. Publish the port with mode: host on the node that runs the server, or put a proxy in front.

Service Where Mounts Secrets
server one replica on a manager Docker socket, /data/kelpie/data all but the Postgres password
agent global, one per node Docker socket, / read-only at /host the agent token
postgres one replica on a manager /data/kelpie/postgres the Postgres password

The agent answers only to the server, over an encrypted overlay network, with the shared agent token. With more than one manager, pin Postgres to one node with a node label instead of node.role == manager.