Repository navigation
fix(chart): run the ext_authz sidecar as a native sidecar (#1275) - #1285
Merged
Merged
Conversation
The authz container was a second regular container in the aether-proxy pod. The kubelet starts regular containers in order without waiting, so it started after `proxy`: when its image had to be pulled (7-13 s on talos-main, the first roll onto OPA 1.21.1) the new Envoy took the node's listeners with nothing behind the authz socket, and every check was an ext_authz error - a 403 under failureMode DENY. On deletion both got SIGTERM at once, so OPA closed its socket while the old Envoy was still serving (successor_wait, drain_fallback). It is now an init container with `restartPolicy: Always`, after install-supervisor and before the proxy container, with a startupProbe: the kubelet starts `proxy` only once the authz socket accepts, and stops the sidecar only after `proxy` has exited. The probe execs the staged stdlib-only proxy-ready prober inside the sidecar's container (the OPA image is distroless with no shell, and a port probe cannot be pod-local on this hostNetwork DaemonSet). proxy-ready gains --unix-socket: exit 0 iff a connect(2) to that AF_UNIX socket succeeds - raw syscall, no net package, so it stays tiny. It is the contract every authz sidecar here already meets, so the default works for the OPA preset and for a bring-your-own image; it is tunable (proxy.authzSidecar.startupProbe.*), replaceable (.override) or disableable (.enabled=false), with optional liveness/readiness probes. Native sidecars need Kubernetes >= 1.29: an older apiserver drops the field and leaves an init container that never exits. With the sidecar enabled the chart refuses to render below 1.29; disabled, nothing changes (the default render is byte-identical apart from the generated webhook certificates). supervisorcmd's chart-flag scan now skips the sidecar, which sits between install-supervisor and the proxy container. Chart 2.4.9. Closes #1275 Co-Authored-By: Claude Fable 5.1 <[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.
What
The ext_authz sidecar (proposal 027) in the
aether-proxypod is now a Kubernetes native sidecar: an init container withrestartPolicy: Always, afterinstall-supervisorand beforeproxy, with a startupProbe on the authz socket. Chart 2.4.9.Closes #1275
Why
authzwas the second regular container. The kubelet starts regular containers in order and does not wait for one before starting the next, soauthzstarted afterproxy. When its image had to be pulled (7–13 s on talos-main, on the first roll onto OPA 1.21.1), the new Envoy took the node's listeners with nothing listening on the authz socket. Every check in that window was anext_authzerror, which is a 403 underfailureMode: DENY. On deletion both containers got SIGTERM at once, so OPA closed its socket while the old Envoy was still serving (successor_waitafterkubectl delete pod, anddrain_fallback).Rendered pod spec (OPA preset on)
initContainersinstall-supervisorinstall-supervisor,authz(restartPolicy: Always,startupProbe)containersproxy,authzproxyWith the sidecar disabled (the default), the full
helm templateoutput is byte-identical to main's, apart from the randomly generated webhook certificates.The probe
execof the stdlib-onlyproxy-readybinary, whichinstall-supervisoralready stages at/opt/aether/proxy-ready. The probe runs inside the sidecar's own container, which mounts thesupervisor-binvolume read-only.proxy-readygets a second mode,--unix-socket=PATH: it exits 0 only if aconnect(2)to that AF_UNIX socket succeeds. It uses rawsyscall, notnet, so the binary stays small (#673). Why this option:hostNetwork, sohttpGet,tcpSocketandgrpcprobes reach whichever pod on the node holds the port (the same reason as mesh-dns: replace exec-marker readiness probe with in-process /healthz (reclaim ~250m fleet CPU) #582). The proxy's own readiness probe already avoids them for this reason.opa:*-envoy-staticis distroless with no shell, and OPA's diagnostic API is already on a per-pod UDS that no kubelet probe can reach./policy/policy.regohas loaded.The probe is configurable:
proxy.authzSidecar.startupProbe.{periodSeconds,timeoutSeconds,failureThreshold}(1 / 1 / 120),.override(a full probe used verbatim),.enabled: false, plus optionallivenessProbeandreadinessProbe(none by default). A liveness kill is itself an authz outage, and a crashed sidecar is restarted in place anyway.What the ordering guarantees across a hot-restart handoff
proxy, and with it the supervisor, the successor Envoy's fork and its takeover of the listeners, starts only after the authz socket accepts. The image pull now delays the new pod instead of the authz path. WithmaxUnavailable: 0the old pod keeps serving meanwhile. A sidecar that never starts leaves the new pod inInitand stops the roll.proxy, so it has its own pod's authz for as long as it runs: insuccessor_wait, indrain_fallback, and while it is the draining hot-restart parent. In a plain DaemonSet surge roll the successor turns Ready only after the parent Envoy has exited (supervisor: on rev242 the old proxy pod gets SIGTERM mid-handoff (6–11 s after the fork, before the successor's readiness gate) in 7 of 15 handoffs #991), so this mostly matters for delete, drain and eviction.Not guaranteed:
failureModeuntil the kubelet restarts it..override.terminationGracePeriodSecondsstill caps everything.Minimum Kubernetes version
Native sidecars are on by default from 1.29 and GA in 1.33. The chart declares no
kubeVersion, and I did not add one: that would gate the whole chart, including users who never enable authz. Instead, withproxy.authzSidecar.enabled, the template fails below 1.29 withproxy.authzSidecar requires Kubernetes >= 1.29 (native sidecar containers) … pass --kube-version. The comparison issemverCompare "<1.29.0-0", so provider suffixes like-eks-pass.I chose to fail rather than fall back. An older apiserver drops the field, which leaves an init container that never exits, so every proxy pod is stuck in
Init. Falling back to the old layout would silently bring back the 403s. With the sidecar disabled, no minimum applies. CI's kind runs 1.35.8. Helm 4.2's built-in default version is ≥ 1.29, so plainhelm templaterenders.Tests
helm_template_test/helm_template_absent_test/helm_template_fail_testincharts/aether/BUILD.bazel:proxyis the only regular containerSeen red before the template change: 7 of the new targets failed (
aether_authz_native_sidecar_test,_byo_test,_startup_probe_override_test,_override_no_default_test,_startup_probe_disabled_test,_kube_version_min_test,_kube_version_too_old_test: "expected 'helm template' to be rejected, but it rendered successfully"). The two disabled-path targets passed, as they should.//agent/cmd/proxy-ready:proxy-ready_test(newTestUnixSocket): listening, stale socket file, missing, regular file, and marker-does-not-rescue cases.deps_teststill passes, so the binary is still stdlib-only.//agent/internal/supervisorcmd's chart-flag scan now skips the sidecar, which sits betweeninstall-supervisorandproxy.Proof
bazel test //charts/... //e2e/... //agent/cmd/proxy-ready/... //agent/internal/supervisorcmd/... //agent/cmd/proxy-supervisor/...: 87/87 passbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: cleanmake format-check: cleane2e/authz.sh; pinned kind v0.33.0 installed into a scratch dir, k8s 1.35.8). The OPA image is evicted from the node before each roll, so the new pod's sidecar must pull it:EXT_AUTHZ_ERRORSsumshttp.*.ext_authz.errorover every HCM on the node, so a request can count under more than one stat prefix. That is why the red run shows 990 errors for 495 × 403.Not verified: the shutdown-side guarantee (old pod's authz alive through
successor_wait/drain_fallback) is from the kubelet's documented native-sidecar termination order. The e2e does not exercise it directly. Not deployed to talos-main.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr