docs: the speech-to-text service's runtime, limits and cache volume
This commit is contained in:
parent
68580a8725
commit
49f5e70e3f
5 changed files with 72 additions and 20 deletions
|
|
@ -258,13 +258,14 @@ instead of the container. The flows and the delivery path:
|
|||
### Speech to text
|
||||
|
||||
The speech-to-text service, in a `swarm-stt` container on the host that sets
|
||||
`deploy.stt.enable`. Run it where the inference hardware is: it transcribes
|
||||
with whisper.cpp. An agent that receives a voice memo sends the audio to it
|
||||
over the queue and gets the text back, and a memo sent to several agents costs
|
||||
one run. `deploy.stt.settings.modelSize` picks the model (`small` by default,
|
||||
or `base`). The audio comes from rooms with outside people, so the service runs
|
||||
under a tight sandbox, but its network isn't restricted, which the design page
|
||||
spells out. The settings, limits and reasons:
|
||||
`deploy.stt.enable`, or as a pod in the host's cluster with
|
||||
`deploy.stt.runtime = "k8s"`. Run it where the inference hardware is: it
|
||||
transcribes with whisper.cpp. An agent that receives a voice memo sends the
|
||||
audio to it over the queue and gets the text back, and a memo sent to several
|
||||
agents costs one run. `deploy.stt.settings.modelSize` picks the model (`small`
|
||||
by default, or `base`). The audio comes from rooms with outside people, so the
|
||||
service runs under a tight sandbox, but its network isn't restricted, which the
|
||||
design page spells out. The settings, limits and reasons:
|
||||
[`stt.md`](../../4-implementation/swarm/stt.md) and
|
||||
[Host setup](../../4-implementation/swarm/stt.md#host-setup).
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ Each of these is a flake package named `image-<daemon>`, and the image name is
|
|||
- `swarm-ci-metrics`
|
||||
|
||||
`nix flake check` evaluates all six and builds none of them, so the workspace
|
||||
compile stays out of CI. `swarm-claude-login`, `swarm-stt` and
|
||||
`swarm-review-classifier` need claude-code, whisper or similar tools in their
|
||||
image and aren't in the set yet.
|
||||
compile stays out of CI. `swarm-claude-login` and `swarm-review-classifier`
|
||||
need claude-code in their image and aren't in the set yet. `swarm-stt` isn't
|
||||
in the set either: [the manifest renderer](manifests.md#pods) builds its image,
|
||||
with the ffmpeg, whisper-cli and model paths its unit's environment names.
|
||||
|
||||
## Tags
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ A service gets manifests on the host whose configuration deploys it:
|
|||
| --------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
|
||||
| `swarm-controller` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-controller-state`, ConfigMap `swarm-controller-etc` |
|
||||
| `swarm-notify-router` | Deployment | ServiceAccount |
|
||||
| `swarm-stt` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-stt-state` |
|
||||
| `swarm-ci-metrics` | CronJob | ServiceAccount, PersistentVolumeClaim `swarm-ci-metrics-state` |
|
||||
|
||||
`namespace.yaml` holds the Namespace. NATS with its auth responder,
|
||||
`swarm-review-classifier`, `swarm-claude-login` and `swarm-stt` have no
|
||||
manifests yet: their images don't exist yet.
|
||||
`swarm-review-classifier` and `swarm-claude-login` have no manifests yet: their
|
||||
images don't exist yet.
|
||||
|
||||
## One source: the unit
|
||||
|
||||
|
|
@ -97,6 +98,15 @@ credential directory.
|
|||
escalation, every capability dropped, the runtime's default seccomp profile,
|
||||
and no mounted API token. A service that logs in to the store gets a token
|
||||
of its own, [below](#the-store-login).
|
||||
- **Resources:** the unit's `MemoryMax` becomes the container's memory limit
|
||||
(systemd's `K`, `M`, `G` and `T` are Kubernetes' `Ki`, `Mi`, `Gi` and `Ti`; a
|
||||
byte count passes unchanged; `infinity` sets none) and its `CPUQuota`, a
|
||||
percent of one core, becomes the cpu limit in millicores (`400%` is
|
||||
`4000m`). The renderer sets no `requests`, so Kubernetes reserves the limits
|
||||
on the node. A value in another form fails evaluation. `TasksMax` has no pod
|
||||
field, so the renderer drops it. The unit's sandbox settings
|
||||
(`MemoryDenyWriteExecute`, `SystemCallFilter`, `PrivateUsers` and the rest)
|
||||
stay on the host: the pod has the security shape above and no other.
|
||||
- **Probes:** a service with an opt-in health listener gets its variable set to
|
||||
`0.0.0.0:8080`, with liveness on `/healthz` and readiness on `/readyz`
|
||||
(see [Readiness checks](../swarm/readiness.md)). `swarm-controller` serves
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ unit, or as a pod in the host's cluster. `services.hyperhive.deploy.<service>.ru
|
|||
is `"host"` (the default) or `"k8s"`. The service runs once per swarm, so the
|
||||
option moves it and never copies it: the host unit and the pod never run
|
||||
together, because they would share one queue consumer and one set of buckets.
|
||||
`swarm-notify-router` has the option today, and the other services that run in
|
||||
the cluster follow the same pattern.
|
||||
`swarm-notify-router` and `swarm-stt` have the option today, and the other
|
||||
services that run in the cluster follow the same pattern.
|
||||
|
||||
## Options
|
||||
|
||||
- `services.hyperhive.deploy.notify-router.runtime` (default `"host"`).
|
||||
`"k8s"` needs `services.hyperhive.deploy.k8s.enable` on the same host, and the
|
||||
evaluation fails without it.
|
||||
- `services.hyperhive.deploy.stt.runtime` (default `"host"`), with the same
|
||||
rule.
|
||||
|
||||
With `"host"`, a host without [the cluster node](node.md) renders the same
|
||||
configuration as before the option existed. With the node on and every service
|
||||
|
|
@ -20,8 +22,9 @@ on `"host"`, the cluster holds no service objects.
|
|||
|
||||
## What `"k8s"` changes
|
||||
|
||||
- **The host unit goes.** The configuration has no `swarm-notify-router`
|
||||
container, no credential hand-ins for it and no journal forwarder for it.
|
||||
- **The host unit goes.** The configuration has no container for the service
|
||||
(`swarm-notify-router`, `swarm-stt`), no credential hand-ins for it and no
|
||||
journal forwarder for it.
|
||||
- **The service's objects go in.** The [rendered manifests](manifests.md) reach
|
||||
the cluster through `services.k3s.manifests`, one file per service plus the
|
||||
namespace. The cluster applies a file when its link appears in the manifests
|
||||
|
|
@ -77,12 +80,38 @@ forge events stream and its `notify-router-state` bucket live in the queue, so a
|
|||
switch in either direction copies nothing, and the router continues from the
|
||||
consumer's position.
|
||||
|
||||
`swarm-stt` keeps a transcript cache, which lives 24 hours. On the host the
|
||||
cache sits in the container's `/var/lib/swarm-stt`. In the cluster it sits in
|
||||
the PersistentVolumeClaim `swarm-stt-state`, mounted at the same path. A switch
|
||||
copies neither: each side starts with the cache it last had, empty the first
|
||||
time, and transcribes a memo that only the other side cached. The claim stays
|
||||
after a switch back, as every claim does, and the container's directory stays
|
||||
too. The whisper model isn't state: the pod's image holds it, from the same
|
||||
store path the container reads, and the volume doesn't.
|
||||
|
||||
## Resources and sandbox
|
||||
|
||||
The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
|
||||
([manifests](manifests.md#pods)), so `swarm-stt` keeps its 3 GiB and four-core
|
||||
ceilings. The pod has no `requests`, so Kubernetes reserves those limits on the
|
||||
node: the node needs that memory and those cores free to schedule the pod.
|
||||
`TasksMax` has no pod counterpart, so the renderer drops it. The systemd sandbox
|
||||
(`MemoryDenyWriteExecute`, `SystemCallFilter`, `PrivateUsers`, the read-only
|
||||
`ProtectSystem` and the rest) stays on the host. The pod is a non-root user with
|
||||
a read-only root filesystem, every capability dropped, the runtime's default
|
||||
seccomp profile and no API token, which is its whole sandbox. Neither side
|
||||
restricts the network.
|
||||
|
||||
## Validation
|
||||
|
||||
`module-eval-k8s` checks that the host render with `"host"` holds the container,
|
||||
no cluster manifests and no CA objects. With `"k8s"` it checks that no container
|
||||
no cluster manifests and no CA objects, and that `swarm-stt`'s container and
|
||||
unit are as the module defines them. With `"k8s"` it checks that no container
|
||||
remains, that the manifests sit in `services.k3s.manifests`, and that the
|
||||
evaluation refuses `"k8s"` without the node. The VM test `k8s-runtime-switch`
|
||||
runs a router against the real secret store and a queue. It switches from the
|
||||
host to the cluster and back, checks each step for exactly one copy, and asserts
|
||||
that the pod logs in, routes an event, and exits 0 when deleted.
|
||||
runs a router and the speech-to-text service against the real secret store and
|
||||
a queue. It switches both from the host to the cluster and back, checks each
|
||||
step for exactly one copy of each, and asserts that the router's pod logs in,
|
||||
routes an event, and exits 0 when deleted. For `swarm-stt` it asserts that the
|
||||
pod is Ready, logged in to the store with its ServiceAccount token, carries the
|
||||
unit's limits, and has its cache volume bound.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,14 @@ model (`small` by default, or `base`), and `modelFile` takes any other ggml
|
|||
model. The cache time, the limits on file size, audio length and run time, and
|
||||
how many requests it holds at once are settings next to it.
|
||||
|
||||
With `deploy.stt.runtime = "k8s"` on a host that runs the cluster
|
||||
(`deploy.k8s.enable`), the service runs as a pod and the host has no container.
|
||||
The pod has the unit's memory and CPU ceilings as limits and its cache on a
|
||||
volume of the cluster. The systemd sandbox stays on the host, and the pod has
|
||||
the security shape every pod has; neither restricts the network. Nothing moves
|
||||
in a switch, so each side keeps the cache it last had; see
|
||||
[the runtime switch](../k8s/runtime.md).
|
||||
|
||||
The audio comes from rooms with outside people, so the service runs as its own
|
||||
unprivileged user under a tight systemd sandbox, with a memory ceiling and
|
||||
a CPU quota. Its network isn't restricted: the decoder runs in the same
|
||||
|
|
|
|||
Loading…
Reference in a new issue