Repository navigation
feat(identity): injected identity-ready init container holds a mesh pod's app containers until its SVID exists — the egress twin of the inbound readiness gate (#1053) - #1055
Merged
Conversation
…od's app containers until its SVID exists — the egress twin of the inbound readiness gate (#1053) A pod that sent within ~8 s of its CNI ADD had no SVID yet: the source proxy had no client certificate for it and connects sat until connect_timeout (503 UF on h2). The CNI ADD is deliberately not blocked (SPIRE must not become a hard dependency of sandbox creation); the app container is gated instead. - agent/cmd/identity-ready: waits on the pod's own SPIRE Workload API (csi.spiffe.io, mounted into the init container only) until an X.509 SVID is issued, then exits 0. Fail closed by default, periodic WARN naming the socket and last error, optional --timeout. Links gRPC + go-spiffe's generated Workload API client only; deps_test holds an explicit module allow-list. Ships as an extra layer in the agent image. - controller/internal/podmutate: injects aether-identity-ready FIRST (ahead of the pod's own init containers) plus its CSI volume into every mesh pod; skips aether.io/identity-gate=false, hostNetwork and mesh-ignored namespaces; idempotent; Pod Security "restricted"-compliant. - chart: controller.webhook.identityGate.{enabled,image,pullPolicy,timeout, resources}, default ON, never rendered with spire.enabled=false; chart 1.0.4. - e2e/eastwest-quic.sh E6: fresh ServiceAccount, request at container start. kind: gate off -> first request stalls 3.4-5.4 s for the cert; gate on -> gate holds 3.6-4.1 s, first request 200 in 12-14 ms as the new SA. - docs: workload requirements, configuration, runbook, proposal 036 follow-up. Closes #1053 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ry-config) 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]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…nch merge of main) 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 29, 2026
Brings #979 up to date with 36 commits of main (demand-scoped twins #1020/#1032, fresh-stream classifier #1033/#1035, dormant-pair ledger #1036/#1038, per-twin EDS names #1012/#1029, the twin certificate gate #1051, the ODCDS always-answer override, --east-west-quic-idle-timeout #1063, L4 stat keys #1043, access-log timing #1048, the identity gate #1055, hot-restart knobs #1068 and the carried Envoy patches) while keeping #979's intent: no allow-list, every destination in the node's dependency set is QUIC-eligible. Resolution: - cache: quicServices / SetEastWestQUICServices removed. armsFor gives arms to every default, identity-ready, non-waypointed entry whose service is in the dependency set (the same rule recordQUICPair admits by, so no route names a twin the agent would refuse); twins stay demand-scoped. The destination_not_quic_enabled refusal/prune reason is gone. - quicpairs: the dependency-set prune now waits for the pod set like the source prune does -- the allow-list used to force its destinations into the set, and without it the first snapshot after an agent restart dropped every restored pair (TestQUICDemandPairSurvivesAgentRestart was red). - fan-out log: allow_listed_services dropped; observed_pairs and awaiting_client_cert kept. - chart 1.0.12: eastWestQuicServices removed, eastWestQuicIdleTimeout and its parentShutdownTime check kept. - e2e/eastwest-quic.sh: main's demand-scoped E1/E4c/E6 + #979's QUIC_DNS_SANS negative control; h2only/E3 removed; E6 dials quic-a and its idgate-* pairs are excluded from the driven-pair count. eastwest-quic-hotrestart.sh's h2 control is now the weighted GAMMA split (the one h2-by-design path). - tests, runbook, soak README, configuration.md, 038 rewritten for the unconditional state. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
Why
A pod that sends within ~8 s of its CNI ADD has no SVID yet: SPIRE delivers the initial SVID only after the pod's registration entry is created and synced to the node's spire-agent (two
svids=0updates, thenupdate=initial7.46 s after the subscribe on talos-main). In that window the source proxy has no client certificate for the pod, connects sit untilconnect_timeout, and the app gets503 UF(h2;503 NCon QUIC before #1051). The inbound side already gates endpoint health on an mTLS handshake with the pod's own inbound listener (#815); egress had nothing.The decision on #1053 (2026-09-28): do not block the CNI ADD. That would make SPIRE a hard dependency of sandbox creation, and the ADD races SPIRE's own pod-list attestation. Gate the app container instead: the netns and sandbox exist, SPIRE attests normally, the app cannot open a socket before its identity exists, and a SPIRE outage shows up as pods in
Initwith a reason instead of as 503s.Design
agent/cmd/identity-ready, a new binary. It waits until the pod's X.509 SVID is obtainable, then exits 0. By default it fails closed: with no timeout it waits forever, and every 10 s it logs a WARN that names the socket and the last Workload API error.--timeoutmakes it exit 1 with a clear message. SIGTERM is reported as an interruption, not as a timeout.Source of truth: the pod's own SPIRE Workload API, read through a
csi.spiffe.iovolume that is mounted into the init container only. The app containers never get the socket. I rejected the alternative, an agent RPC over a host-local UDS, because it has the bigger blast radius:baselineprofile rejects. A CSI volume is allowed even underrestricted.The Workload API answers from the same spire-agent cache that the agent's Broker API stream is fed from, and controller-manager entries carry only
k8s:pod-uid, which the init container matches. The proxy fetches the client certificate on demand at connect time (Make the source-identity filter state Hashable so the mesh can drop connection_pool_per_downstream_connection #842/Inbound validation context accepts any trust-domain member: pin a spiffe://<td>/ns/*/sa/* URI SAN prefix #843), so there is no settle delay. Measured on kind: after release, the first request took 12–14 ms.Dependencies: gRPC, protobuf and go-spiffe's generated
proto/spiffe/workloadclient only. It does not useworkloadapi/x509svid, so no go-jose. The binary is 11.4 MB, 8 modules.//agent/cmd/identity-ready:deps_testreads the embedded build info and asserts an explicit module allow-list, plus a forbidden-package scan and a size ceiling. It is not stdlib-only, so there is nodeps_testclaiming that.Image: an extra layer (
/identity-ready) in the agent image, following theproxy-readypattern. The agent DaemonSet already has that image on every node, so the gate costs no extra pull and cannot skew from the agent.container_test.yamlasserts the file is there.Injection (
controller/internal/podmutate/identitygate.go):aether-identity-readyfirst among init containers, so it also holds the pod's own init containers and native sidecars.aether-identity-gate-spiffe.restrictedprofile: nonroot 65532, read-only root filesystem, drop ALL, RuntimeDefault seccomp.terminationMessagePolicy: FallbackToLogsOnError, sokubectl describeshows why a pod is held.aether.io/identity-gate: "false",hostNetwork, and mesh-ignored namespaces (gating SPIRE's own namespace would deadlock SPIRE's bootstrap).Knob and annotation
controller.webhook.identityGate.enableddefaults to true. The chart always renders--identity-gate=true|false, and it forcesfalsewhenspire.enabled=false, because no SVID would ever come.identityGate.image.*(empty meansagent.image),pullPolicy(defaultIfNotPresent: the image is digest-pinned and already on the node),timeout(empty means wait forever) andresources.--identity-gate,--identity-gate-image,--identity-gate-image-pull-policy,--identity-gate-workload-socket(=spire.workloadSocketPath),--identity-gate-timeout, and--identity-gate-{cpu,memory}-{request,limit}. A bad value fails controller startup, not admission.aether.io/identity-gate: "false"(annotations.AnnotationIdentityGate).Tests
--timeoutargument.aether.io/managed=false, hostNetwork, andspire-mgmt/aether-system/kube-system.--config=race.common/spire/spiretest:errTimedOutnaming the socket and the last SPIRE error. An attempt cut short by the deadline no longer overwrites that error; race × 20 runs was clean.main()exit codes are covered in a subprocess: 0 when ready, 1 on timeout.helm_template_tests:aether_identity_gate_default_test(the agent image from quay by digest,IfNotPresent, the socket path and resources),_disabled_test,_no_spire_testand_overrides_test(timeout plus mirror image).bazel test //controller/... //agent/cmd/... //charts/... //common/constants/... //e2e/...: 42/42 passed. Lint withfail_on_violation,make format-check,make gazelle,make tidyandmake deps-auditare all clean.//test/envoy_validateis untouched; there is no xDS change.e2e evidence (kind,
e2e/eastwest-quic.sh, new phase E6 +idgatesubcommand)E6 creates a ServiceAccount that did not exist a second earlier and a bare Pod whose container sends its first request to
h2onlythe instant it starts. E6 asserts four things: the init containers start withaether-identity-ready, it exited 0, the first request is200, and the XFCCURI=is the new SA's own SPIFFE ID.IDENTITY_GATE=off)spiffe://aether.internal/ns/aether-test/sa/idgate-…With the gate off, the agent log for the same pods shows the talos-main shape: subscribe, then
svids=0twice, thenupdate=initial3.9–5.9 s later.The red arm did not reproduce as a 503 on kind. kind's SPIRE issued the SVID inside the mesh cluster
connect_timeout, so the gate-off first request stalled (the missing-cert wait) rather than failing. On talos-main the window is ~7.5 s, which crossesconnect_timeoutand becomes 503 UF. E6 reports the first request's status and latency in both modes and asserts only the gate-on contract.A full
verify(E0–E6) with the gate on passed. That run also covers E5, which deletesclient-a's pod; it came back gated and still carried its own identity over HTTP/3. The kind cluster was deleted and the kube context restored totalos-main.Docs
docs/workload-requirements.md: a new section, "Identity before the first request".docs/configuration.md: the knob rows and a pod-annotation table.docs/runbook.md: "Pod held in Init by aether-identity-ready (A pod that sends within its first ~8 s has no SVID yet: SPIRE delivers the initial SVID ~7.5 s after the agent subscribes (two empty updates first) — h2 requests fail 503 UF connection_timeout / UO in that window (was 503 NC on QUIC before #1051) #1053)", with a table of what eachlast_errormeans.CLAUDE.md: the binary is added to the Binaries list.Closes #1053
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr