Watch
0
0
Fork
You've already forked hyperhive
0

bind health listeners to the pod's loopback and probe them by exec

This commit is contained in:
atlas 2026-11-27 23:45:00 +01:00
commit 62cc95671d
3 changed files with 255 additions and 185 deletions

View file

@ -10,9 +10,12 @@ One image runs one daemon. Its contents are:
- the daemon's per-bin package from `nix/packages/default.nix`,
- the CA roots from `pkgs.cacert`, with `SSL_CERT_FILE` pointing at them,
- the binary's own closure, which is glibc and libgcc.
- the binary's own closure, which is glibc and libgcc,
- for a daemon with a health listener, `wgetOnly` (`wget` and nothing else of
busybox): the listener binds to the pod's loopback, and the pod's `exec`
probes run it against `http://127.0.0.1:<port>`.
The image has no shell and no init. The kubelet restarts a crashed container, so a
The image has no shell and no init (`wget` is the one tool it may add). The kubelet restarts a crashed container, so a
service manager inside it would only disagree with the kubelet. A missing
shell also leaves nothing to `exec` into. The entrypoint is `/bin/<bin>`, and
the process runs as the `serviceUser` uid and gid that `nix/images/default.nix`
@ -36,12 +39,13 @@ 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-review-classifier` and
compile stays out of CI. All but `swarm-ci-metrics`, which has no health
listener, hold `wgetOnly`. `swarm-claude-login`, `swarm-review-classifier` and
`swarm-stt` aren't in the set: [the manifest renderer](manifests.md#pods) builds
their images, with the paths their units' environments name (claude-code and
opencode, ffmpeg, whisper-cli and the model). It builds three more for the
queue's pod ([runtime](runtime.md#the-queue)): the NATS server, which also
holds `wget`, the one tool of busybox its readiness probe needs; the
queue's pod ([runtime](runtime.md#the-queue)): the NATS server, which holds
`wgetOnly` for its readiness probe, as the daemons' images do; the
Prometheus exporter; and an image of the queue's init and renewal scripts.
## Tags

View file

@ -142,18 +142,24 @@ credential directory.
a listener and `egress` (`swarm-logs-auth`, `swarm-metrics-auth`) has the one policy: it admits the
node to the listener and nothing else, and allows the egress above.
- **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
`127.0.0.1:8080`, with liveness on `/healthz` and readiness on `/readyz`
(see [Readiness checks](../swarm/readiness.md)). The kubelet's `httpGet`
probes dial the pod's IP, so these are `exec` probes: each runs `wget` from
the image (`wgetOnly`, in `nix/images/default.nix`) against the loopback URL
in the container, with a 5-second timeout, and a 503 fails it. The pod
declares no port for the listener. `swarm-controller` is one of
them, with `SWARM_CONTROLLER_HEALTH_ADDR`. A third-party daemon with no health variable,
`victoria-logs` and `victoria-metrics`, names a `probe` path instead (`/health`), which both probes
request on its listener. A `startupFailureThreshold` in it (`victoria-metrics`, 60) adds a
startup probe on the same path, tried every ten seconds, before the other two begin. The health port takes no credential, because the
kubelet's probes carry none and the routes answer a status code with no body.
Only the node reaches it, through the namespace's default-deny
ingress policy and the pod's own policy, which admit no other pod and no
client of the bridge. The port is an exception to mara's ruling ("if you can reach
it, even just in the cluster, it needs auth"): the kubelet has no credential
to send.
startup probe on the same path, tried every ten seconds, before the other two begin.
The health listener of our own daemons is unreachable from outside the pod: the
node, other pods and the bridge get a refusal, so it needs no credential.
The one health route outside the pod is the `/health` of `victoria-logs` and
`victoria-metrics` on their main port. Upstream answers `/health`, `/ping`,
`/-/healthy` and `/-/ready` before it checks `-httpAuth`, and the gateway needs
the main port on the pod's IP, so no bind or probe can close it. It's
reachable from the node only, through the default-deny ingress policy, and it
returns a status and no data.
- **Listener and init container:** a service with a TCP `listener`
(`swarm-controller`, with `swarm.controller.tcp.enable`) publishes its port
with a ClusterIP Service, admits only the node to it with a NetworkPolicy, and

View file

@ -166,7 +166,7 @@ of more than one node needs one before the controller may run there.
the controller on the host the locations dial that name. The Service has a
NetworkPolicy that selects the pod for ingress and allows nothing: the
cluster's policy engine always admits traffic from an address of the node, so
the gateway's connection and the kubelet's probes reach the pod, and no other
the gateway's connection reaches the pod, and no other
pod does. A Service works on a cluster of more than one node, but the
controller's Deployment still has the one replica.
- **The listener's leaf.** The pod issues its own, from the store's
@ -186,8 +186,9 @@ of more than one node needs one before the controller may run there.
`swarmctl` reaches the controller only through the gateway: run
`swarmctl login` once. The host's wrapper defaults `--swarm` to the host's own
swarm and sets no socket path, since a socket path on the host serves nothing.
- **Probes.** The pod binds `SWARM_CONTROLLER_HEALTH_ADDR`, with liveness on
`/healthz` and readiness on `/readyz`. Readiness needs the queue connection
- **Probes.** The pod binds `SWARM_CONTROLLER_HEALTH_ADDR` on the pod's
loopback, with liveness on `/healthz` and readiness on `/readyz`, both `exec`
probes of `wget` in the container. Readiness needs the queue connection
and a fresh store login, so a store role that refuses the pod's token leaves
it NotReady.
- **State.** `/var/lib/swarm-controller` is an `emptyDir`. The record of the
@ -254,7 +255,7 @@ strategy, and the removed container stops before the pod can start.
client, and only the node may read it. The pod's NetworkPolicy selects it for
ingress and allows the client port from any source and nothing else. The
cluster's policy engine always admits traffic from an address of the node, so
the gateway and the kubelet's probes reach the pod, and a pod of the cluster,
the gateway reaches the pod, and a pod of the cluster,
or a client of the bridge that the host forwards, doesn't reach the exporter.
- **The exporter's login.** The node's processes reach the exporter too, so it
asks every request for a login. The exporter's container runs with
@ -321,7 +322,7 @@ strategy, and the removed container stops before the pod can start.
The claim and its volume stay until the operator deletes them, as every claim
does, with the directory.
- **Readiness.** The pod is Ready when the responder's `/readyz`, on the pod's
port 8080, passes and the server's exec probe does. The probe runs
loopback port 8080, passes and the server's exec probe does. The probe runs
`wget` against `/healthz?js-enabled-only=true` on the server's monitor, which
stays on the pod's loopback; the server's image holds `wget` and nothing else
of busybox.
@ -423,7 +424,7 @@ writes to the store and Grafana that reads it.
Security `restricted` refuses a `hostPath` for it.
- **Who reaches what.** Both pods have a NetworkPolicy that selects them for
ingress and allows none, so only the node's own traffic reaches them: the
host's nginx, which dials the Services, and the kubelet's probes. The policy
host's nginx, which dials the Services, and the kubelet's `/health` probe. The policy
refuses a pod of the cluster. The log store asks for its credential on every route, so a
process on the host that dials the Service gets 401: see
[the stores' listener credential](#the-stores-listener-credential). The responders' policy
@ -507,13 +508,14 @@ pushes to the store and Grafana that reads it.
the pod has one ServiceAccount and one jwt role of that name, and both read the
store with the pod's token. They hold no state, so the pod has no node label
and runs on any node. Each serves TCP (`--listen`) on 8083 and 8084 behind a
Service of its own. The second container names its ports `grafana-api` and
`grafana-health`: a Service resolves a named port to the first container of the
pod that declares the name, so a shared name would send Grafana's bearer to the
agents' responder.
Service of its own. The second container names its port `grafana-api`: a Service
resolves a named port to the first container of the pod that declares the
name, so a shared name would send Grafana's bearer to the agents' responder.
Each container's health listener (8085 on the second) binds to the pod's
loopback, and the kubelet runs `wget` in the container against it.
- **Who reaches what.** Both pods have a NetworkPolicy that selects them for
ingress and allows none, so only the node's own traffic reaches them: the
host's nginx, which dials the Services, and the kubelet's probes. The store
host's nginx, which dials the Services. The store
asks for its credential on every route, so a process on the host that dials the
Service gets 401: see [the stores' listener credential](#the-stores-listener-credential).
The responders' policy also lets the pod reach cluster DNS and the secret
@ -557,8 +559,8 @@ seccomp profile and no API token.
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
admits no ingress. The pod's health listener binds to its loopback and the
kubelet probes it from inside the container, and the pod doesn't serve anything
else: requests reach it as queue messages, over the connection it opens. The
policy also allows the pods of the queue's
load balancer, in `kube-system`, on the queue's port, because the node forwards