require k8s: swarm services with a pod run in the cluster only
This commit is contained in:
parent
23865cb223
commit
44670249b6
1 changed files with 1044 additions and 3125 deletions
|
|
@ -40,7 +40,9 @@ under `deploy.nats` or `swarm.nats`, fails at eval with a message naming the
|
|||
option and where the keys live now.
|
||||
|
||||
To replace either key, delete both of its paths the way the xkey's section
|
||||
below shows for the xkey, then restart `swarm-bao-nats-callout-xkey`.
|
||||
below shows for the xkey, then delete the queue's pod (`kubectl -n hyperhive delete pod
|
||||
--selector app.kubernetes.io/name=swarm-nats`): its init container creates the keys
|
||||
again.
|
||||
|
||||
One consequence worth knowing before you debug it: the queue assembles its
|
||||
config each time the server starts rather than at build time, in every mode,
|
||||
|
|
@ -63,14 +65,14 @@ Only the `swarm-nats-auth` role reads either path, and it may create each but
|
|||
never replace it. The policy of `swarm-secret-publisher`, which writes the rest
|
||||
of `swarm/services/`, denies it the seed's path.
|
||||
|
||||
On the queue's host, `swarm-bao-nats-callout-xkey` runs before the
|
||||
`swarm-nats` container, under the responder's store leaf:
|
||||
The queue pod's `callout-config` init container runs before the server and the
|
||||
responder, under the pod's `swarm-nats-auth` login:
|
||||
|
||||
1. `swarm-nats-auth ensure-callout-keys` creates the pair when the store holds no
|
||||
seed, and otherwise only reads it. It needs no queue, so on a first boot
|
||||
the key exists before the server that needs it.
|
||||
2. It reads the public half back from the store into
|
||||
`/var/lib/nats-callout/callout-xkey.pub` inside the container.
|
||||
`/var/lib/nats-callout/callout-xkey.pub` in the pod's config volume.
|
||||
3. Each time `nats-server` starts, it renders that key into
|
||||
`auth_callout.xkey`. With no file, the server doesn't start.
|
||||
4. The responder starts after the server and reads the seed from the store.
|
||||
|
|
@ -78,31 +80,15 @@ On the queue's host, `swarm-bao-nats-callout-xkey` runs before the
|
|||
requests it can't open.
|
||||
|
||||
The store has to be reachable each time the responder starts. When it's down,
|
||||
the fetch unit fails and retries for a day. The server starts with the key
|
||||
fetched last time, or not at all on a first boot. A responder that starts
|
||||
the init container fails and the pod doesn't start its server. A responder that starts
|
||||
while the store is down exits and retries, first after 5 seconds and then
|
||||
after longer waits up to a minute, and until one start reads the seed the
|
||||
queue refuses every client, OIDC ones included. The retry that lands the file
|
||||
starts or restarts the server, and the responder comes up with it.
|
||||
starts the server, and the responder comes up with it.
|
||||
|
||||
The responder always comes back. Its unit has `Restart=always` and no start
|
||||
limit, so a burst of starts can't leave it failed. A stop that comes from the
|
||||
server failing isn't a restart trigger, so every host script that restarts
|
||||
the server in `swarm-nats` (`swarm-bao-nats-tls` on a leaf rotation,
|
||||
`swarm-bao-nats-callout-xkey` after fetching the keys) also clears the
|
||||
responder's failed state and starts it. Those scripts use `start`, not
|
||||
`restart`: the server's restart already restarts a running responder, which loads
|
||||
the current seeds.
|
||||
|
||||
Those starts can still fail: a start job fails when a unit the responder
|
||||
requires, the server or the container's trust bundle, fails first, and a
|
||||
failed job leaves the responder inactive, out of `Restart=`'s reach. Both
|
||||
units therefore uphold it (systemd's `Upholds=`): while either one runs, systemd starts
|
||||
an inactive or failed responder, and the unit that comes up last starts it with
|
||||
both up. This also means stopping the responder or the server by hand inside
|
||||
the container lasts only as long as the stop itself: systemd starts the
|
||||
responder again, and the responder pulls the server back in. To keep it down,
|
||||
mask it, or stop the container.
|
||||
The responder is the pod's main container: the kubelet restarts a container that
|
||||
exits, and a deleted pod starts the server and the responder again, so the
|
||||
responder loads the current seeds.
|
||||
|
||||
The responder's store leaf is `deploy.nats.authBaoClientCertFile` /
|
||||
`authBaoClientKeyFile`. On the store's host both default to the leaf
|
||||
|
|
@ -114,26 +100,22 @@ name it in both options. Until you do, evaluation fails naming both.
|
|||
Where the queue and the store run on different hosts, deploy the store's host
|
||||
first. `swarm-bao-nats-auth-policy` there writes the role's grants on the
|
||||
keys' paths, and `swarm-bao-secret-publisher-policy` the publisher's denial of
|
||||
the seeds' paths; where the queue runs on that host too, the fetch waits for
|
||||
both. A queue host deployed before it can't read or create the keys, so its
|
||||
fetch fails, and the queue refuses every client until you deploy the store's
|
||||
host: the server starts only on public keys fetched before, and the responder
|
||||
can't load its seeds. Seed files the import is waiting for stay where they
|
||||
are. If that takes longer than the fetch's day of retries, run
|
||||
`systemctl restart swarm-bao-nats-callout-xkey` on the queue's host.
|
||||
the seeds' paths. A queue host deployed before it can't read or create the keys, so
|
||||
its init container fails, and the queue refuses every client until you deploy
|
||||
the store's host: the server doesn't start, and the responder can't load its seeds. If that takes longer than the init container's retries, delete the queue's
|
||||
pod.
|
||||
|
||||
Two starts that create the key at once can't both win: each write is a
|
||||
create that fails once the path holds anything, and the start that lost reads
|
||||
the winner's key back.
|
||||
|
||||
To replace the key, remove both paths with their metadata and every version,
|
||||
then restart the fetch unit on the queue's host. Its restart of `nats.service`
|
||||
restarts the responder too, which then loads the new seed:
|
||||
then delete the queue's pod. The new pod's responder loads the new seed:
|
||||
|
||||
```sh
|
||||
bao kv metadata delete secret/swarm/services/swarm-nats/callout/xkey-seed
|
||||
bao kv metadata delete secret/swarm/public/swarm-nats/callout-xkey
|
||||
systemctl restart swarm-bao-nats-callout-xkey
|
||||
kubectl -n hyperhive delete pod --selector app.kubernetes.io/name=swarm-nats
|
||||
```
|
||||
|
||||
`bao kv delete` isn't enough. It deletes the latest version but keeps the
|
||||
|
|
|
|||
Loading…
Reference in a new issue