Expand description
Builds the planner input from Kanidm and Kubernetes lists. Observe the world the token planner decides on.
observe reads Kanidm (tokens on the dedicated account) and the
Kubernetes API (Deployment template, ReplicaSets, pods, owned config
Secrets) with live list calls, never the controller cache, and returns a
TokenWorld. Everything that interprets objects is a pure function over
k8s_openapi values so it can be tested from fixtures.
The in-use scan is the safety net for revocation: missing a consumer revokes a live token. It therefore errs toward counting:
- Pods are scanned across the namespace, not by label. A pod counts when it is not Succeeded/Failed (Terminating pods count) and carries a token-id annotation that can name one of our tokens (on the account, on one of our config Secrets, or unparsable), carries our UID label, or mounts a config Secret we identify as ours. Another server’s pods in the same namespace carry the annotation too but are not ours.
- A mounted Secret is ours when it is an owned Secret, when its name has
the content-addressed shape
<cr>-<10 hex>(so a Secret that was already deleted is still recognised), or when a pod with our UID label projects itsradius.tomlkey. Every such name is reported inConsumer::config_secretseven if the Secret no longer exists, so the planner sees an unresolved reference instead of nothing. - ReplicaSets count while they have replicas, found through the Deployment owner reference or our UID label.
- Annotation values are passed to the planner raw.
Structs§
- Drain
Observation - What the finalizer needs from Kubernetes: our Deployment (a foreign one of the same name is not ours to wait for or delete) and every ReplicaSet or pod that still uses one of our config Secrets or tokens.
- Observation
- The planner input plus the bearer the current template runs with.
- Observed
Objects - Everything read from the API and Kanidm for one observation.
- Secret
Scope - Names of config Secrets that are ours.
Functions§
- build_
world - Assemble the planner input from already-read objects. Pure.
- config_
secrets - Config Secrets of ours that
specmounts, sorted and unique. - is_
our_ replicaset - Is this ReplicaSet ours: controlled by our Deployment, or labelled with our UID (the Deployment template label, so it also finds ReplicaSets whose Deployment is already gone)?
- observe
- Observe Kanidm and Kubernetes for one reconcile.
- observe_
drain - Kubernetes-only scan used during deletion; reads no Kanidm state.
- observed_
secret - An owned config Secret as planner input.
- observed_
tokens - Tokens on the account as planner input.
- owned_
secrets - Keep only Secrets controlled by this CR. The UID label alone is not ownership: a foreign Secret carrying our label is ignored.
- pod_
consumer - Consumer for a pod, or
Nonewhen the pod is finished (Succeeded or Failed) or has nothing to do with us. Terminating pods count: their containers may still authenticate until they exit. - replicaset_
consumer - Consumer for one of our ReplicaSets, or
Nonewhen it has no replicas. - replicaset_
has_ replicas - A ReplicaSet counts only while it wants or has replicas.
- secret_
bearer - The bearer stored in a config Secret, if present and non-empty UTF-8.
- template_
ref - What the Deployment pod template points at.