k8s: pods log in to the secret store with their ServiceAccount token
The store gets a listener for the pods that asks for no client certificate, open on the pod network's interfaces only, and a jwt auth mount with one role per in-cluster service. The rendered pods run under a ServiceAccount with a projected token in place of their client certificate.
This commit is contained in:
parent
cad1b7cebe
commit
d1554def7a
1 changed files with 720 additions and 69 deletions
|
|
@ -19,11 +19,11 @@ cluster.
|
|||
|
||||
A service gets manifests on the host whose configuration deploys it:
|
||||
|
||||
| service | workload | other objects |
|
||||
| --------------------- | ---------- | -------------------------------------------------------------------------------- |
|
||||
| `swarm-controller` | Deployment | PersistentVolumeClaim `swarm-controller-state`, ConfigMap `swarm-controller-etc` |
|
||||
| `swarm-notify-router` | Deployment | none |
|
||||
| `swarm-ci-metrics` | CronJob | PersistentVolumeClaim `swarm-ci-metrics-state` |
|
||||
| service | workload | other objects |
|
||||
| --------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
|
||||
| `swarm-controller` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-controller-state`, ConfigMap `swarm-controller-etc` |
|
||||
| `swarm-notify-router` | Deployment | ServiceAccount |
|
||||
| `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
|
||||
|
|
@ -38,7 +38,8 @@ The renderer reads the service's evaluated unit, not a copy of its settings:
|
|||
directory it stands for. On a host with a hive collector, the OTLP endpoint
|
||||
variables point at it ([Pod logs and metrics](telemetry.md)) instead. The
|
||||
renderer fails if the unit's `path` holds anything beyond the NixOS default
|
||||
tools, because the image doesn't carry them.
|
||||
tools, because the image doesn't carry them. The other change is the store
|
||||
login, [below](#the-store-login).
|
||||
- **Files:** the pod mounts each file the unit names at the same path,
|
||||
so the environment carries over unchanged:
|
||||
- credentials at `/run/credentials/<service>.service/<id>`, from the Secret
|
||||
|
|
@ -85,7 +86,8 @@ object.
|
|||
with `fsGroup` its gid so the pod reads its credentials (mode `0440`),
|
||||
read-only root filesystem with an `emptyDir` on `/tmp`, no privilege
|
||||
escalation, every capability dropped, the runtime's default seccomp profile,
|
||||
and no service account token.
|
||||
and no mounted API token. A service that logs in to the store gets a token
|
||||
of its own, [below](#the-store-login).
|
||||
- **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
|
||||
|
|
@ -96,6 +98,31 @@ object.
|
|||
- **Rollout:** each Deployment has one replica and the `Recreate` strategy,
|
||||
because each service runs once per swarm.
|
||||
|
||||
## The store login
|
||||
|
||||
A service that has a role at the store's `jwt-k8s` auth mount
|
||||
(`services.hyperhive.deploy.bao.k8sPrincipals`) logs in with its pod's
|
||||
ServiceAccount token. A unit logs in with the client certificate in its
|
||||
environment, so the pod differs from the unit in these places:
|
||||
|
||||
- **ServiceAccount:** one named like the service, in the rendered namespace,
|
||||
with `automountServiceAccountToken: false`, and the pod runs under it.
|
||||
- **Token:** a projected volume `bao-token` with one `serviceAccountToken`
|
||||
source for the audience `bao`, expiring after 600 seconds (the shortest the
|
||||
API server grants) and mounted read-only at `/var/run/secrets/hyperhive/bao`.
|
||||
The kubelet rewrites the file before it expires, and the client reads it
|
||||
afresh at each login. The store's role for the service accepts this
|
||||
account and this audience only.
|
||||
- **Environment:** the pod sets neither `BAO_CLIENT_CERT` nor
|
||||
`BAO_CLIENT_KEY`, and the credentials they named aren't in the pod's
|
||||
Secret. `BAO_AUTH=jwt`, `BAO_JWT_FILE`, `BAO_JWT_ROLE` (the service's name)
|
||||
and `BAO_JWT_MOUNT` (`jwt-k8s`) take their place, and `BAO_ADDR` names the
|
||||
store's own name at the port of the listener that asks for no client
|
||||
certificate (`deploy.bao.podListenerPort`). `BAO_CACERT` stays.
|
||||
|
||||
[The cluster node](node.md#logging-in-to-the-secret-store) describes the
|
||||
store's side.
|
||||
|
||||
## Not covered yet
|
||||
|
||||
- The pods reach the swarm's host-run services (store, queue, identity
|
||||
|
|
|
|||
Loading…
Reference in a new issue