run attic as a swarm service with deploy.attic.enable
This commit is contained in:
parent
f59ed01353
commit
458a046b8d
1 changed files with 1242 additions and 66 deletions
|
|
@ -259,8 +259,8 @@ grant the forge refuses fails the build with no verdict.
|
|||
## Binary cache
|
||||
|
||||
With `services.hyperhive.swarm.attic.domain` and `cache` set, the builder pushes
|
||||
each green meta build's closure to that cache, an attic server outside the swarm,
|
||||
before it replies. It runs `attic push swarm:<cache> <out path>` once per build,
|
||||
each green meta build's closure to that cache, an attic server inside or outside the
|
||||
swarm, before it replies. It runs `attic push swarm:<cache> <out path>` once per build,
|
||||
not `attic watch`, and the builder pushes again when the controller runs a build again. The
|
||||
push has ten minutes, or less when the reply is due sooner, because it must end
|
||||
inside the 61 minutes the controller waits. `attic` checks the server's certificate
|
||||
|
|
@ -271,8 +271,8 @@ Set both options or neither: evaluation refuses a domain without a cache name.
|
|||
The cache name follows attic's rule, 1 to 50 letters, digits, `-`, `_` or `+`,
|
||||
starting with a letter or digit, and evaluation refuses any other name.
|
||||
|
||||
The push token is the operator's to write. The builder reads it on every push
|
||||
from `secret/swarm/services/attic/push-token` (field `value`), writes it to
|
||||
The push token is the swarm's own cache's to create, or the operator's to write for an
|
||||
external one. The builder reads it on every push from `secret/swarm/services/attic/push-token` (field `value`), writes it to
|
||||
a file and an `attic` config naming that file (`token-file`) in the unit's private
|
||||
runtime directory (`/run/swarm-builder`, mode `0700`, both files `0600`), points
|
||||
`attic` at the config with `XDG_CONFIG_HOME` and removes both after the push.
|
||||
|
|
@ -294,6 +294,43 @@ Mixed versions:
|
|||
|
||||
A record written before the field existed also reads as `false`.
|
||||
|
||||
### The swarm's own cache
|
||||
|
||||
`services.hyperhive.deploy.attic.enable` runs an attic server in a `swarm-attic`
|
||||
container behind the gateway, at `attic.<swarm domain>`. It defaults on where
|
||||
you set `deploy.allSwarmServices` and the host holds the cache's store identity
|
||||
(`deploy.bao.atticClient{Cert,Key}File`, which the store's host mints). You write
|
||||
no secret: on first start, two host units log in to the store as the cache's own
|
||||
principal and create what's missing.
|
||||
|
||||
- `swarm-bao-attic-secret` creates the key atticd signs tokens with at
|
||||
`secret/swarm/services/attic/jwt-secret` and writes it where the container
|
||||
reads it.
|
||||
- `swarm-bao-attic-tokens` creates the cache and mints the push token, which
|
||||
the builder reads, at `secret/swarm/services/attic/push-token`, and a
|
||||
read-only pull token for the hives at `secret/swarm/services/attic/pull-token`.
|
||||
|
||||
A unit creates each secret only while the store holds none, so a second start
|
||||
mints nothing. Both tokens last ten years and nothing renews them. To replace one,
|
||||
write the new token to its path in the store: nothing mints over a value that
|
||||
exists. A new signing key invalidates both tokens.
|
||||
|
||||
With the switch on, `swarm.attic.domain` and `swarm.attic.cache` default to
|
||||
`attic.<swarm domain>` and `swarm`, so the builder on that host pushes to it.
|
||||
Naming either option yourself wins over its default. The defaults apply only on
|
||||
the host that runs the cache: on any other host, name both options too, with the
|
||||
same values.
|
||||
|
||||
Storage is local disk in the container's state (`/var/lib/swarm-attic`). A store
|
||||
path nobody added or fetched for 14 days goes at the next garbage collection,
|
||||
which runs every 12 hours (`deploy.attic.retentionPeriod`). The next build of
|
||||
that agent pushes a closure the cache lost.
|
||||
|
||||
The gateway terminates TLS with a swarm services certificate and forwards to
|
||||
`127.0.0.1:8910` (`deploy.attic.port`) with no login in front: attic checks its
|
||||
own tokens, and a nix client can't follow a login redirect. The container logs
|
||||
to its journal only; its journal doesn't reach the swarm log store.
|
||||
|
||||
### External cache
|
||||
|
||||
The cache can be an attic tenant on an instance outside the swarm. To point
|
||||
|
|
@ -313,10 +350,12 @@ pins nothing, so a Let's Encrypt certificate needs no setup. The builder
|
|||
reads the token again on every push, so a new token takes effect on the next
|
||||
build.
|
||||
|
||||
A later change adds the swarm's own attic service: `deploy.attic.enable` will run atticd
|
||||
in the swarm and fill these two options itself. An operator who sets that option
|
||||
to false keeps the external cache by setting the two options by hand and
|
||||
seeding the token as above.
|
||||
Where you host the shared services, `deploy.attic.enable` defaults on and runs
|
||||
the swarm's own cache. To use an external one, set it to `false` with
|
||||
`lib.mkForce`, then set the two options by hand and seed the token as above.
|
||||
The swarm then renders no container, vhost or unit of its own cache, and
|
||||
creates no secret in the store. The store's host still mints the cache's
|
||||
leaf and writes its role, which nothing logs in to.
|
||||
|
||||
## Credentials
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue