Watch
0
0
Fork
You've already forked hyperhive
0

k8s: stt's pod gets a network policy: dns and four host ports out, nothing in

This commit is contained in:
atlas 2026-11-23 13:36:51 +01:00 • committed by maia
commit 2259b5f27b
4 changed files with 262 additions and 22 deletions

View file

@ -23,7 +23,7 @@ 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 |
| `swarm-stt` | Deployment | ServiceAccount, NetworkPolicy `swarm-stt` |
| `swarm-review-classifier` | Deployment | ServiceAccount |
| `swarm-claude-login` | Deployment | ServiceAccount |
| `swarm-ci-metrics` | CronJob | ServiceAccount, PersistentVolumeClaim `swarm-ci-metrics-state` |
@ -113,6 +113,16 @@ credential directory.
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.
- **Network:** a service whose entry has `egress` (`swarm-stt`) gets a
NetworkPolicy named after it, selecting its pods for ingress and egress. It
allows no ingress; its egress is cluster DNS (the CoreDNS pod, port 53) and,
on the hive bridge's address, one TCP port per host service the entry names:
the store's pod listener (`store`), the gateway's 443 for the identity
provider (`identity`), the queue's port (`queue`) and the hive collector's
(`collector`). Where the queue runs in the cluster, its pod on its port is
allowed too. The node trusts the pod network's interfaces, so without the
policy a pod reaches every port of the host. A service without `egress` has no
policy.
- **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` is one of

View file

@ -28,6 +28,10 @@ service images loaded and no service's objects applied.
bridge's default subnet.
- **Firewall:** the pod network's interfaces, `cni0` and `flannel.1`, are
trusted, so the node reaches its pods.
- **NetworkPolicy:** k3s's own controller (kube-router, iptables) enforces
NetworkPolicy objects; the node doesn't turn it off. A pod no policy selects
reaches whatever it can route to. [The manifests](manifests.md#pods) say which
pods have one.
- **Secret store:** the store gets a second listener and an auth mount for the
pods' ServiceAccount tokens, described under
[Logging in to the secret store](#logging-in-to-the-secret-store).

View file

@ -92,9 +92,10 @@ Job:
cluster doesn't apply it again. The rename also records what remains to
delete. With no link, nothing went in, so the unit does nothing and needs no
cluster.
2. Wait for the cluster's API, then delete the service's Deployment, CronJob and
ServiceAccount (selected by `app.kubernetes.io/name`), and wait until its pods
have gone. A pod exits 0 within its termination grace period.
2. Wait for the cluster's API, then delete the service's Deployment, CronJob,
NetworkPolicy and ServiceAccount (selected by `app.kubernetes.io/name`), and
wait until its pods have gone. A pod exits 0 within its termination grace
period.
3. Delete the cluster's AddOn for the file, so that a later switch to `"k8s"`
applies the same manifest again. Then remove the renamed link.
@ -274,12 +275,20 @@ 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 requests nothing (memory `0`, cpu `0`, as the unit sets no
`MemoryMin` or `MemoryLow`), so the node reserves nothing for it and the pod is
Burstable. `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.
Burstable. `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. The host unit doesn't
restrict the network. The pod has a NetworkPolicy (`swarm-stt`, rendered with
the pod): it may reach cluster DNS, and on the node's bridge address the store's
pod listener, the identity provider, the queue and the hive collector, each on
its one port. It admits no ingress. The kubelet's probes still reach the pod,
because the node's own traffic to a pod is always admitted, and the pod doesn't
serve anything else: requests reach it as queue messages, over the connection it
opens. Where the queue runs in the cluster, the policy also allows the queue's
pod on its port, because the node forwards the queue's `hostPort` to the pod
before the policy sees the packet.
## Telemetry and credentials of the poller

View file

@ -101,16 +101,18 @@ 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 security shape every pod has. The pod's NetworkPolicy lets it reach cluster
DNS and the store, identity provider, queue and hive collector on the host and
nothing else, and admits no ingress. 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
network namespace as the service and can read its credentials, so a decoder
unprivileged user under a tight systemd sandbox, with a memory ceiling and a CPU
quota. In the container its network isn't restricted: the decoder runs in the
same network namespace as the service and can read its credentials, so a decoder
exploit could read them and send them anywhere the container can reach. Closing
that's for the strict-egress work on service containers, or for running the
decode with no network and no credentials. The file's first bytes must look like an audio container
before anything decodes it. Its leaf and its queue client work as the notification router's
do.
decode with no network and no credentials. In the pod the policy limits where
they can go to those four host services. The file's first bytes must look like
an audio container before anything decodes it. Its leaf and its queue client
work as the notification router's do.