k8s: stt's pod runs in a user namespace of its own
This commit is contained in:
parent
02cc38d89e
commit
4e60183bfa
3 changed files with 111 additions and 26 deletions
|
|
@ -101,6 +101,11 @@ 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).
|
||||
`swarm-stt` also runs in a user namespace of its own (`hostUsers: false`), as
|
||||
the unit's `PrivateUsers` does: its root and every id it holds are
|
||||
unprivileged ids on the node. A volume keeps the in-pod ownership it has
|
||||
without one, so `fsGroup` and the credential files' mode work as before.
|
||||
A service asking for it needs a kernel of 6.3 or later (an assertion).
|
||||
- **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
|
||||
|
|
@ -110,9 +115,9 @@ credential directory.
|
|||
cap on the node. The memory request is the unit's `MemoryMin`, else its
|
||||
`MemoryLow`, else `0`, and the cpu request is `0`, so the pod is Burstable. 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.
|
||||
renderer drops it. The unit's sandbox settings (`MemoryDenyWriteExecute`,
|
||||
`SystemCallFilter` 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,
|
||||
|
|
|
|||
|
|
@ -276,19 +276,20 @@ The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
|
|||
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. 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.
|
||||
systemd sandbox (`MemoryDenyWriteExecute`, `SystemCallFilter`, the read-only
|
||||
`ProtectSystem` and the rest) stays on the host, and `PrivateUsers` is the pod's
|
||||
own user namespace (`hostUsers: false`). 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
|
||||
|
||||
|
|
|
|||
|
|
@ -101,10 +101,11 @@ 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. 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 security shape every pod has, in a user namespace of its own as the unit has
|
||||
`PrivateUsers`. 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue