Repository navigation
feat(agent): subscribe SVIDs by k8s selectors instead of resolving PIDs - #77
Merged
Merged
Conversation
The agent used --spire-trust-domain for two unrelated things: peer authorization (where the RootCATrustDomain "ROOTCA" sentinel means "authorize any") and constructing SPIFFE IDs / SDS resource names for Envoy listeners. With the sentinel default, the agent named secrets spiffe://ROOTCA/... while SPIRE (and the SPIRE bridge) issue spiffe://<real-td>/... (e.g. aether.internal), so Envoy's SDS requests never matched the delivered secrets and inbound mTLS never came up (secrets stuck warming, upstream 503). Resolve the real workload trust domain from the SPIRE Workload API SVID at startup and use it for listener SDS naming (xDS + CNI servers). --spire-trust-domain now governs only peer authorization, as documented, and may remain the RootCATrustDomain sentinel. The Workload API source is opened once and shared with the registrar client instead of being created per consumer. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Replace the PID-based SPIRE delegated-identity subscription with selector-based
subscription. The agent already learns a pod's identity from the kube-apiserver
(namespace, service account, name, UID) in enhanceCNIPod, so it subscribes via
SubscribeToX509SVIDs{Selectors: k8s:ns/sa/pod-name/pod-uid}. SPIRE issues the SVID
of the entry the spire-controller-manager binds by k8s:pod-uid — no process
attestation, so no container PID is needed.
This removes an entire fragile, runtime-coupled stack and its failure modes:
- the netns->PID inode resolution (which resolved the pause/sandbox PID that
SPIRE's k8s attestor times out on),
- the post-CNI-ADD retry for the sandbox process to appear,
- and the host privileges it required: drop hostPID and CAP_SYS_PTRACE from the
agent DaemonSet.
Subscription is now synchronous in CmdAdd and race-free (identity is known
immediately). This mirrors how CNI-based meshes (e.g. Istio ambient/ztunnel)
integrate workload identity.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
… ladder owns escalation (#766) Seen on the GitOps #77 phase-2 spire-agent roll (2026-09-19 12:03-12:06Z): 39 ERROR lines, one per managed pod, next to the 117 Unavailable ones the previous commit already demotes. Resubscribe was 17.2-17.8s per node at zero prober cost. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
… ladder owns escalation (#766) Seen on the GitOps #77 phase-2 spire-agent roll (2026-09-19 12:03-12:06Z): 39 ERROR lines, one per managed pod, next to the 117 Unavailable ones the previous commit already demotes. Resubscribe was 17.2-17.8s per node at zero prober cost. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 19, 2026
…wns the recovery (#766) (#807) * fix(agent,edge): designed startup retries log at WARN, and name who owns the recovery (#766) Three sites logged ERROR for a retry that is expected to fail once and heals by itself, so "zero ERROR lines" stopped being a usable bar for deploy and soak grading. Each keeps ERROR for the case where the excuse no longer holds. - xDS initial snapshot (the edge): the edge does not hold its first snapshot for identity, so with no SVID yet it cannot handshake with the registrar, exhausts the 15s budget and starts local-only — at ERROR, on every healthy roll. It now gets a severity-only view of its identity (SetIdentityWatch): WARN while the SVID is pending, and the background retry escalates to ERROR once if identity arrives and three more loads still fail. With the SVID in hand the ERROR is unchanged. The node agent is unaffected (it holds for identity first). - Broker subscribe (the agent): Unavailable is WARN until the subscription has been failing for 2 minutes (the readiness dwell), then ERROR. A restarted agent resubscribes before its own SVID has landed, and a SPIRE agent restart removes the socket for ~35s: both cost one ERROR per managed pod per attempt and healed in seconds at zero prober cost. - Pod termination (the agent): the failed DRAINING mark has a fallback and is WARN. The fallback failing too stays ERROR — a terminating pod remains selectable — unless this agent's SVID is pending, when no registry call could have succeeded. The message said "CNI DEL will retry"; since #798 a DEL does not retry against an agent that is down, so it now names the real owners: the pod's CNI DEL or the next ghost sweep. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(agent): an established Broker stream ending is WARN; the bridge's ladder owns escalation (#766) Seen on the GitOps #77 phase-2 spire-agent roll (2026-09-19 12:03-12:06Z): 39 ERROR lines, one per managed pod, next to the 117 Unavailable ones the previous commit already demotes. Resubscribe was 17.2-17.8s per node at zero prober cost. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * refactor(agent): split the two severity decisions into helpers (gocognit) CI's cognitive-complexity lint rejected retryInitialRegistryLoad and handlePodTerminating after the previous commits; behaviour unchanged. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #76 (uses the derived trust domain for the SPIFFE ID).
Why
The PID-based SPIRE delegated-identity subscription couldn't get a workload SVID: the agent resolved the pod's sandbox/pause PID from its netns, and SPIRE's k8s workload attestor times out attesting that PID (
Timed out collecting selectors for PID) — the pause container isn't in the kubelet's container list. So no SVID was issued and inbound mTLS never came up.Change
Subscribe by Kubernetes selectors instead of a PID. The agent already learns the pod's identity from the kube-apiserver in
enhanceCNIPod(namespace, service account, name, and now UID), so it callsSubscribeToX509SVIDs{Selectors: k8s:ns/sa/pod-name/pod-uid}. SPIRE returns the SVID of the entry the spire-controller-manager binds byk8s:pod-uid(confirmed in its source:entries.gosetsk8s:pod-uid:<pod.UID>) — no process attestation, no container PID.Removes an entire fragile, runtime-coupled stack
pid.go) — the source of the sandbox-vs-app-PID problem,hostPIDandCAP_SYS_PTRACEfrom the agent DaemonSet (reverts the additions from fix(agent): resolve sandbox PID for SVID subscription after CNI ADD #72/fix(agent chart): grant SYS_PTRACE so the agent can resolve sandbox PIDs #74).Subscription is now synchronous in
CmdAddand race-free (identity is known immediately). This mirrors how CNI-based meshes (Istio ambient/ztunnel) integrate workload identity.Net: +63 / −293.
Trade-off
Moves from SPIRE-attested identity to delegate-asserted identity (SPIRE trusts the authorized delegate's selectors). Acceptable for a CNI agent that already controls pod networking and reads identity from the authenticated API server — and it removes a security-sensitive host capability.