Repository navigation
feat(authbridge): Add envoy-sidecar mTLS demo - #440
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughAdds envoy-sidecar mTLS demo: updated docs and binary comment clarifying Envoy-terminated TLS, runtime and Envoy ConfigMaps for permissive/strict modes, caller/callee Kubernetes manifests with sidecars and operator-required labels, Makefile targets, and scripts to swap configs and verify mTLS behavior end-to-end. ChangesEnvoy-sidecar mTLS Demo and Documentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@authbridge/demos/mtls/Makefile`:
- Around line 54-59: The current comment incorrectly states that targets mutate
`envoy-config` and rely on `scripts/swap-envoy-config.sh` to backup/restore;
update it to reflect the actual behavior: the demo uses
`envoy-config-mtls-active` (not `envoy-config`) and performs a clean deletion
flow instead of in-place backup/restore, so remove the backup/restore wording
and clarify the real interaction with `envoy-config-mtls-active`; keep the note
about `proxy-sidecar` and `envoy-sidecar` to avoid confusion but adjust any
concurrency guidance to match the new config-swap behavior.
In `@authbridge/demos/mtls/README.md`:
- Around line 218-221: The README.md has fenced code blocks lacking language
tags (triggering MD040); update the first block that starts with "spiffe.mirror:
initial x509 write" to use a language identifier (e.g., ```text) and update the
second block that begins with the kubectl command to use a shell/console
identifier (e.g., ```console) — make the change for both occurrences noted
(lines around the spiffe.mirror error block and the kubectl/... | jq block) so
the Markdown linter recognizes the block types.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9894047b-6b9a-4b5d-9f16-fd83d3710fed
📒 Files selected for processing (14)
authbridge/CLAUDE.mdauthbridge/cmd/authbridge-envoy/main.goauthbridge/demos/mtls/Makefileauthbridge/demos/mtls/README.mdauthbridge/demos/mtls/k8s/authbridge-runtime-mtls.yamlauthbridge/demos/mtls/k8s/callee-envoy.yamlauthbridge/demos/mtls/k8s/callee.yamlauthbridge/demos/mtls/k8s/caller-envoy.yamlauthbridge/demos/mtls/k8s/caller.yamlauthbridge/demos/mtls/k8s/envoy-config-mtls.yamlauthbridge/demos/mtls/scripts/swap-envoy-config.shauthbridge/demos/mtls/scripts/verify-encrypted-envoy.shauthbridge/demos/mtls/scripts/verify-permissive-envoy.shauthbridge/demos/mtls/scripts/verify-strict-rejects-plain-envoy.sh
6666d9e to
0c004be
Compare
Hand-crafted demo proving mTLS works at the Envoy data-plane level for
authBridgeMode=envoy-sidecar — inbound termination via tls_inspector +
filter_chain_match (matching Istio's PERMISSIVE/STRICT inbound and
proxy-sidecar's tlssniff byte-peek), outbound origination via
UpstreamTlsContext on the cluster (Istio-shaped, blanket TLS-or-fail
in strict, plaintext in permissive). X.509 SVIDs read from /opt by
Envoy directly via DownstreamTlsContext / UpstreamTlsContext file
references; the in-process spiffe Provider mirror keeps them fresh.
The demo bypasses operator pod injection entirely — SPIFFE identity
auto-registers via the cluster's default ClusterSPIFFEID
(spiffe://<trust-domain>/ns/<ns>/sa/<sa>) so a ServiceAccount-bound
pod is enough. This sidesteps two operator bugs that would otherwise
block the demo (RO /opt mount on envoy-sidecar's envoy-proxy
container, and per-agent CM reconciliation eating user-added fields).
The README's "Operator bugs uncovered" section documents them in
detail; the kagenti-operator follow-up PR will fix both.
The same operator CM-reconcile bug also breaks the existing
proxy-sidecar make demo-mtls — patch-mtls-config.sh writes
mtls:{mode:strict} into the per-agent CM, the operator reverts it
before the pod can mount it, and authbridge boots logging
mTLS-disabled. This PR also fixes the proxy-sidecar Pod manifests so
they at least admit and roll out (adds the kagenti.io/type: agent
label the operator's mutating webhook objectSelector requires, plus
an explicit runAsUser: 100 to satisfy runAsNonRoot against the
curlimages/curl regression). Verification still depends on the
kagenti-operator follow-up.
Verified end-to-end against a kind+kagenti+SPIRE cluster: caller to
callee succeeds in both strict and permissive; strict rejects
plaintext at filter chain match; SVIDs land in /opt on both ends;
Envoy admin /config_dump shows tls_inspector + DownstreamTlsContext
wired up.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
0c004be to
4479ac0
Compare
mrsabath
left a comment
There was a problem hiding this comment.
Well-constructed demo for envoy-sidecar mTLS. The README's Status (2026-05-27) callout at the top makes the operator-bug situation clear, and the design table + "behavioral gap vs proxy-sidecar" section are precise about how envoy-sidecar permissive differs from proxy-sidecar permissive. Configs reference SVID paths that match what the in-process SPIFFE Provider mirror writes. Shell scripts use set -euo pipefail and quote variables. The Go change is a comment-only correction. The fix to existing proxy-sidecar manifests (kagenti.io/type: agent label + numeric runAsUser: 100) is necessary unrelated cleanup that's worth the small scope creep.
No must-fix or suggestion-level findings — this is a demo directory and the work is appropriate for that bar.
Areas reviewed: Go (comment), YAML/K8s manifests, Shell, Makefile, Docs
Commits: 1 commit, signed-off
CI status: all checks passing
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
authbridge/demos/mtls/README.md (1)
218-221:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd language identifiers to both fenced code blocks.
The fences starting at Line 218 and Line 238 are still unlabeled, so MD040 continues to fail. Please add explicit language tags (e.g.,
textfor the log excerpt andconsolefor kubectl output).Also applies to: 238-254
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@authbridge/demos/mtls/README.md` around lines 218 - 221, The README.md contains two unlabeled fenced code blocks (one showing a log excerpt starting with 'spiffe.mirror: initial x509 write' and the other showing kubectl output) causing MD040 failures; update those triple-backtick fences in authbridge/demos/mtls/README.md by adding explicit language identifiers (e.g., change ``` to ```text for the log excerpt block and to ```console for the kubectl output block) so the markup linter recognizes them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@authbridge/demos/mtls/scripts/verify-encrypted-envoy.sh`:
- Around line 46-50: The kubectl jsonpath currently indexes containerStatuses[0]
in the pod selection command (the pod=$(kubectl ... -o 'jsonpath=...') line),
which is flaky; change the jsonpath filter to check the Pod Ready condition or
the named container readiness instead (e.g., check
.status.conditions[?(@.type=="Ready")].status=="True" or
.status.containerStatuses[?(@.name=="envoy-proxy")].ready) so the selection only
returns pods that are fully Ready (or whose envoy-proxy container is ready)
before taking head -1.
---
Duplicate comments:
In `@authbridge/demos/mtls/README.md`:
- Around line 218-221: The README.md contains two unlabeled fenced code blocks
(one showing a log excerpt starting with 'spiffe.mirror: initial x509 write' and
the other showing kubectl output) causing MD040 failures; update those
triple-backtick fences in authbridge/demos/mtls/README.md by adding explicit
language identifiers (e.g., change ``` to ```text for the log excerpt block and
to ```console for the kubectl output block) so the markup linter recognizes
them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bd9e578b-3ee4-4372-8d8b-dd54197bc705
📒 Files selected for processing (14)
authbridge/CLAUDE.mdauthbridge/cmd/authbridge-envoy/main.goauthbridge/demos/mtls/Makefileauthbridge/demos/mtls/README.mdauthbridge/demos/mtls/k8s/authbridge-runtime-mtls.yamlauthbridge/demos/mtls/k8s/callee-envoy.yamlauthbridge/demos/mtls/k8s/callee.yamlauthbridge/demos/mtls/k8s/caller-envoy.yamlauthbridge/demos/mtls/k8s/caller.yamlauthbridge/demos/mtls/k8s/envoy-config-mtls.yamlauthbridge/demos/mtls/scripts/swap-envoy-config.shauthbridge/demos/mtls/scripts/verify-encrypted-envoy.shauthbridge/demos/mtls/scripts/verify-permissive-envoy.shauthbridge/demos/mtls/scripts/verify-strict-rejects-plain-envoy.sh
✅ Files skipped from review due to trivial changes (3)
- authbridge/demos/mtls/scripts/verify-strict-rejects-plain-envoy.sh
- authbridge/cmd/authbridge-envoy/main.go
- authbridge/CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (6)
- authbridge/demos/mtls/k8s/caller.yaml
- authbridge/demos/mtls/k8s/authbridge-runtime-mtls.yaml
- authbridge/demos/mtls/scripts/verify-permissive-envoy.sh
- authbridge/demos/mtls/k8s/callee-envoy.yaml
- authbridge/demos/mtls/k8s/caller-envoy.yaml
- authbridge/demos/mtls/k8s/envoy-config-mtls.yaml
Summary
make demo-mtls-envoy*) — proves the Envoy data-plane mTLS design (tls_inspector+ filter chain match for inbound,UpstreamTlsContextfor strict outbound) works end-to-end with SPIRE X.509 SVIDs.kagenti.io/type: agentlabel + explicitrunAsUser: 100) so they at least admit and roll out under the current operator's tightened webhook selectors.Design
mtlsModedisabled(default)permissivetls_inspector+ two filter chains: TLS chain terminates mTLS, raw_buffer chain accepts plaintextstricttls_inspector+ single TLS chain; plaintext rejected at chain matchUpstreamTlsContext: TLS-or-fail, blanketInbound is byte-identical to proxy-sidecar's
tlssniff.Listenersemantics, expressed as Envoy filter chains — matches Istio's PERMISSIVE/STRICT inbound exactly.Outbound is Istio-shaped: no per-connection try-then-fallback. Blanket TLS in strict mode is practical because outbound calls that need plaintext (Keycloak / JWKS / external HTTPS) never reach the listener — plugin outbound uses Go
net/httpdirectly, andproxy-init's iptables redirects only plaintext HTTP to the outbound listener.Behavioral gap to know: a permissive envoy-sidecar caller cannot reach a strict peer (its outbound is plaintext; the peer's strict inbound rejects it). proxy-sidecar permissive can, because its outbound dialer tries TLS first per-connection. Documented in
authbridge/CLAUDE.mdand the demo README.Why hand-crafted (not operator-injected)
The demo uses its own pod manifests with no
kagenti.io/injectlabel. SPIFFE identity auto-registers via the cluster's defaultClusterSPIFFEIDtemplate (spiffe://<trust-domain>/ns/<ns>/sa/<sa>). This sidesteps two operator bugs that would otherwise block the demo entirely — see "Operator bugs uncovered" in the demo README.Operator bugs uncovered
Verified empirically during e2e testing. The kagenti-operator follow-up PR needs to address #1 and #2 in addition to its originally-planned scope.
/optmountedreadOnly:trueon envoy-sidecar'senvoy-proxycontainer (asymmetric with proxy-sidecar's RW). The in-process spiffe Provider mirror can't write SVID files; Envoy refuses to boot.authbridge-config-<name>ConfigMaps and erases user-added fields (mtls:,spiffe.mirror_dir, etc.) before the pod can mount them. Affects both the existing proxy-sidecarmake demo-mtlsand the envoy-sidecar variant. Either preserve user fields in reconcile, or makeSpec.MTLSModeon the AgentRuntime CR the canonical source.objectSelectorrequireskagenti.io/typein[agent, tool]. Demo manifests didn't have it. Fixed in this PR.Test plan
Verified e2e on a kind + kagenti + SPIRE cluster (kagenti chart
0.3.0-alpha.1, authbridge-envoy:latest):make demo-mtls-envoy— strict mode caller→callee succeeds; SVIDs mirrored to/opt; Envoy admin/config_dumpshowstls_inspector+DownstreamTlsContext.make demo-mtls-envoy-strict-rejects-plain— external plaintext call rejected at filter chain match.make demo-mtls-envoy-permissive— external plaintext call served by theraw_bufferchain.make undeploy-envoy— clean teardown.make demo-mtlsadmits + rolls out (was failing on selector + curl runAsUser before this PR). Verification still fails on operator bug 2 — documented.kubectl apply --dry-run=clienton all 6 manifests,bash -non all 8 scripts,go vet ./cmd/authbridge-envoy/....Follow-up (separate PR, not blocking this one): re-run on a fresh cluster after the kagenti-operator follow-up PR lands and confirm the operator-injected path produces the same Envoy YAML this demo ships by hand.
Assisted-By: Claude (Anthropic AI) [email protected]
Summary by CodeRabbit
New Features
Documentation
Bug Fixes