Skip to content

Replace SPIRE's Delegated Identity API with the SPIFFE Broker API in the node agent (and delete the admin-socket path) #800

Closed as not planned

Description

@bpalermo

Why

The node agent mints per-pod SVIDs through SPIRE's proprietary Delegated Identity API on the agent admin socket, authorised by authorizedDelegates, with hand-built selectors (agent/internal/spire/bridge.go PodSelectors: k8s:ns, k8s:sa, k8s:pod-name, k8s:pod-uid). That has three costs: (1) registration entries keyed on any other selector (pod labels, container image, sigstore) never match, because the delegate — not SPIRE — decides the selector set; (2) the admin socket is an all-or-nothing capability (any selector → any identity on the node); (3) it is SPIRE-specific and drags github.com/spiffe/spire-api-sdk into the module for one package.

The SPIFFE Broker API (spiffe/spiffe#340, merged 2026-06-16) standardises exactly this role: a broker presents a workload reference, the SPIFFE provider attests the referenced workload itself, and the broker is authenticated by mTLS with its own SVID and authorised by SPIFFE ID (optionally RBAC-scoped through a Kubernetes SubjectAccessReview).

Everything required is already in the versions we run: SPIRE agent 1.15.2+ implements it (experimental.broker; talos-main runs 1.15.3), Helm chart spire-0.30.2 (what GitOps pins) exposes sockets.broker, brokerAPI.brokers.<key> and workloadAttestors.k8s.brokerAPI, and go-spiffe v2.8.1 (pinned in go.mod) ships the stubs at exp/proto/spiffe/broker.

This is a replacement, not an opt-in: the goal is to delete the delegated path, the admin-socket plumbing and the spire-api-sdk dependency.

Design decisions (made here so the PR does not re-litigate them)

  • Reference type: KubernetesObjectReference{type:{plural:"pods", group:"core"}, key:{namespace,name}, uid} — both key and uid, so SPIRE verifies the UID of the pod it resolved (spec §3.1.3). pod_reference_scope stays agent_node (kubelet pod-list fast path; a node agent only ever brokers local pods). WorkloadPIDReference is not used.
  • Transport: UDS only (unix:///…/csi.spiffe.io/broker/broker.sock), never TCP. Every call carries the broker.spiffe.io: true metadata via a client interceptor (unary + stream).
  • mTLS: client cert = the agent's own SVID from the existing common/spire.WaitingSource (so agent: startup is fatally coupled to the SPIRE Workload API — a 25 s SVID wait exits the process (2–4 restarts per node on every cold boot; #662 family) #740 semantics carry over unchanged: no SVID yet ⇒ the bridge waits, never exits). Server authorizer = SPIFFE ID in our trust domain under /spire/agent/ (the SPIRE agent's own ID), per the endpoint spec §5 requirement to authenticate the provider.
  • Bundles: the Broker bundle stream needs a workload reference, which the bridge does not have on a node with zero pods. Validation contexts are therefore built from (a) the agent's own Workload API bundle set via WaitingSource (always available once identity is) and (b) the union of federated_bundles carried on each pod's SVID stream. fix(agent): make SPIRE bridge SDS publication monotonic; never publish an empty trust-bundle set (#772) #784's guarantees stay: single-writer monotonic publication, and never publish an empty validation-context set over a non-empty one.
  • Errors (spec §4.8 / endpoint §6): NotFound/FailedPrecondition for a reference (pod not yet in the kubelet list at CNI ADD, or no entry yet) ⇒ retry with the existing jittered backoff and count it; PermissionDenied ⇒ ERROR + metric, keep retrying slowly (policy may be non-static); Unauthenticated ⇒ refresh from WaitingSource and redial; InvalidArgument ⇒ programming error, ERROR, no retry; Unavailable ⇒ backoff (SPIRE outage: same as today).
  • Access policy: ship with the chart's accessPolicy: auto (= permissive while access is node-local UDS). Moving to enforced (SubjectAccessReview for verb impersonate-via-spire on the pod, username = the agent's SPIFFE ID) is Phase 3, after the replacement has soaked.
  • What does not change: the SDS secret naming and the Transient cross-service mTLS identity mis-binding during concurrent proxy-restart + service roll (failed closed) #638 inbound/outbound identity discriminator, the node SVID path (refreshNodeSVID), the edge/controller/registrar (they use the plain Workload API), the xDS hold while identity is pending.

Phases

Phase 0 — platform, additive (GitOps repo; keeps the admin socket so rollback stays trivial)
clusters/talos-main/spire/values.yaml: spire-agent.sockets.broker.{enabled: true, mountOnHost: true}; spire-agent.brokerAPI.brokers.aether-agent.{enabled: true, idTemplate: "spiffe://{{ .TrustDomain }}/ns/aether-system/sa/aether-agent", allowedReferenceTypes: [{typeURL: "type.googleapis.com/spiffe.broker.KubernetesObjectReference", allowOverTCP: false}]}; spire-agent.workloadAttestors.k8s.brokerAPI.{accessPolicy: auto, brokers.aether-agent.enabled: true}. The SPIRE agent DaemonSet rolls; verify aether_*_spire_svid_ready stays 1, the socket appears at /run/spire/agent/sockets/csi.spiffe.io/broker/broker.sock on every node, and grpcurl -unix -rpc-header 'broker.spiffe.io: true' … list answers from a debug pod.

Phase 1 — aether (one PR, hard switch)

  • agent/internal/spire/client.go → Broker client (dial with WaitingSource mTLS + authorizer + metadata interceptor; SubscribeX509SVID(ctx, podRef)), behind a small interface so tests use a fake server.
  • bridge.go: SubscribePod(netns, spiffeID, ref PodRef) replaces the selector form; PodSelectors deleted; bundle loop replaced by the Workload-API bundle watcher + per-pod federated bundles; streams, resubscribe/backoff, UnsubscribePod, fix(agent): make SPIRE bridge SDS publication monotonic; never publish an empty trust-bundle set (#772) #784 ordering and the S11 guard preserved; new metrics aether.agent.spire.broker.{reference_not_found,permission_denied} seeded at 0.
  • converter.go: SVIDToTLSCertificateSecret takes the broker X509SVID (DER chain + PKCS#8 key + bundle); the delegated-type converter and its 552-line test are rewritten against the new type.
  • CNI server call site passes namespace/name/UID (already in the CNI ADD args and storage) instead of selectors.
  • Flags/config: --spire-broker-socket (default /run/spire/broker-sockets/broker.sock) replaces --spire-admin-socket; constants.DefaultSpireAdminSocketPath removed; TestRetiredFlagsGone gains the old flag.
  • Chart (charts/aether, version bump): spire.adminSocket.* → spire.brokerSocket.{hostPath: /run/spire/agent/sockets/csi.spiffe.io/broker, mountPath: /run/spire/broker-sockets, socketName: broker.sock}; DaemonSet arg, volume and mount renamed; drop the admin-socket-specific securityContext/group comment if it no longer applies (check the broker socket's ownership/mode on the node first).
  • Dependency cleanup: github.com/spiffe/spire-api-sdk leaves go.mod (only agent/internal/spire imports it — verified); make tidy, scripts/go-deps-audit.sh clean; use_repo shrinks.
  • Tests: a fake Broker server (under common/spire/spiretest) enforcing the metadata header and mTLS; cases for rotation, federated-bundle union, NotFound→retry→success (the CNI ADD race), PermissionDenied, SPIRE outage + late identity (agent: startup is fatally coupled to the SPIRE Workload API — a 25 s SVID wait exits the process (2–4 restarts per node on every cold boot; #662 family) #740 parity: port bridge_late_identity_test.go and bridge_reconnect_test.go), fix(agent): make SPIRE bridge SDS publication monotonic; never publish an empty trust-bundle set (#772) #784 ordering under --config=race.
  • e2e harnesses: e2e/multicluster_{replicator,waypoint}.sh (and any other script installing SPIRE) move SPIRE_CHART_VERSION 0.28.4 (SPIRE 1.14.5 — no Broker API) → 0.30.2, replace authorizedDelegates + sockets.admin.mountOnHost with the broker values above; check spire-crds version compatibility.
  • Docs: docs/configuration.md, docs/getting-started.md, README.md (SPIRE prerequisites: chart ≥ 0.30, the three values blocks), runbook SPIRE section, CLAUDE.md/AGENTS.md package line; proposals 003/015 are historical.

Phase 2 — platform cleanup (GitOps, after Phase 1 has been live for one soak)
Remove spire-agent.authorizedDelegates and spire-agent.sockets.admin. Until then helm rollback aether to the pre-switch revision still works.

Phase 3 — hardening
accessPolicy: enforced + RBAC granting impersonate-via-spire on pods to user spiffe://aether.internal/ns/aether-system/sa/aether-agent (the chart can create it: workloadAttestors.k8s.brokerAPI.brokers.aether-agent.impersonation); measure SubjectAccessReview load and CNI ADD latency impact; consider namespace-scoped grants (mesh-managed namespaces only).

Validation on talos-main (Phase 1)

Hitless roll graded as usual (prober 0 errors per node); every managed pod gets its SVID (SDS secret count == managed pod count; no secret absent WARN beyond the normal ~8 s convergence); #638 mismatch counters 0 across a proxy roll; pod churn (svc-N rollouts) with reference_not_found retries observed and converging; an SVID rotation observed on a live stream; SPIRE outage Tier 1 + Tier 2 from #740 (agents never exit, xDS held, recovery on attestation); a label-selector ClusterSPIFFEID test entry proves the new capability (an identity the delegated path could not have matched); then the 8 h soak before Phase 2.

Risks

  • SPIRE marks the Broker API experimental (config may change before 1.16/1.17; open upstream issues spire broker api identity spiffe/spire#7151, #7007, #7264). Mitigation: GitOps pins chart 0.30.2 / SPIRE 1.15.3; treat any SPIRE bump as needing the e2e SPIRE scripts green first.
  • CNI ADD races the kubelet pod list (reference resolution is "must exist at request time"); agent: k8s: coordinate kubelet pod list fetching spiffe/spire#7085 reduced attestation latency in 1.15.3, and the retry path above covers the rest — measure it.
  • Hard switch means a chart/agent built after Phase 1 requires SPIRE ≥ 1.15.2 with the broker enabled: call it out as a breaking change in the release notes and docs/getting-started.md.

Cleanup inventory (what disappears)

--spire-admin-socket + SpireAdminSocketPath + DefaultSpireAdminSocketPath; PodSelectors and the selector plumbing through the CNI server; the delegated client/stream types in client.go/bridge.go/converter.go; github.com/spiffe/spire-api-sdk and its indirects; chart spire.adminSocket.*; GitOps authorizedDelegates + sockets.admin; the admin-socket paragraphs in four docs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Activity

  1. added
    enhancement
    on Sep 18, 2026
  2. bpalermo commented on Sep 18, 2026

    @bpalermo
    OwnerAuthor

    Tracked as a decision record instead: proposal 036 (docs/proposals/036_spiffe-broker-api.md, PR #801), the project's ADR form. Status there is Accepted; implementation work will reference the proposal rather than this issue. Platform Phase 0 stays on bpalermo/k8s-talos-main#77.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions