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.
Requirements
Section titled “Requirements”- 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.
opensslon the manager, to generate the agent token and the database password.
Create the secrets
Section titled “Create the secrets”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):
docker run --rm ghcr.io/denniedev/kelpie:0.2.10 generate-key > secret-keydocker run --rm ghcr.io/denniedev/kelpie:0.2.10 generate-age-key > age-keyage-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:
docker secret create kelpie_secret_key secret-keygrep '^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.
Deploy
Section titled “Deploy”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:
mkdir -p /data/kelpie/data /data/kelpie/postgresexport KELPIE_IMAGE=ghcr.io/denniedev/kelpie:0.2.10docker stack deploy -c docker-compose.yml kelpiePin 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:
docker exec -it "$(docker ps -q -f name=kelpie_server)" kelpie create-adminThen log in as admin and continue with Your first stack.
Reverse proxy
Section titled “Reverse proxy”Traefik
Section titled “Traefik”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:
docker network create -d overlay --attachable traefikCompose containers can join that network too.
Other proxies
Section titled “Other proxies”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.
Settings for any proxy
Section titled “Settings for any proxy”KELPIE_PUBLIC_URL: the external address, such ashttps://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 fromX-Forwarded-For. Swarm overlay networks use10.0.0.0/8unless the Swarm was set up with another address pool.
Client addresses
Section titled “Client addresses”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-Forwith its own. On the entrypoint, list the CDN’s ranges underforwardedHeaders.trustedIPs; Cloudflare publishes them at cloudflare.com/ips. - Kelpie has to trust both: add the same ranges to
KELPIE_TRUSTED_PROXIESafter thetraefiknetwork, 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.
What runs where
Section titled “What runs where”| 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.