Skip to content

docs(authbridge): document sidecar injection labels and feature gates - #1782

Merged
huang195 merged 1 commit into
rossoctl:release-0.6from
mrsabath:docs/authbridge-injection-modes
Jun 2, 2026
Merged

huang195 merged 1 commit into
rossoctl:release-0.6from
mrsabath:docs/authbridge-injection-modes

Conversation

@mrsabath

@mrsabath mrsabath commented Jun 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds a new Verifying and Tuning Sidecar Injection section to docs/authbridge/deployment-guide.md that closes the documentation gap surfaced in #1775. The existing mode coverage (proxy-sidecar / envoy-sidecar / waypoint) is unchanged — this PR adds the label model on top of it.

Why

A user following the basic weather-agent demo today sees 3/3 Running containers (agent envoy-proxy spiffe-helper) but the demo's verification step claims 2/2. There is no canonical page that explains:

  • How to inspect what was injected.
  • What the kagenti.io/inject, kagenti.io/spire, and per-sidecar *-inject labels do.
  • Which container set to expect under which combination.
  • Where the cluster-admin feature gates (kill switches) live.

This PR makes that information discoverable from one section, sourced directly from kagenti-operator/internal/webhook/injector/pod_mutator.go and precedence.go (the production paths), so it stays consistent with reality.

What's new

The new section contains:

  1. A kubectl one-liner to print containers + labels for a workload.
  2. A "containers per mode + label combination" table — explicitly covers the 2/2 vs 3/3 cases users actually see, including the kagenti.io/inject=disabled opt-out.
  3. Workload-level controls — opt-out label vocabulary with defaults and effects.
  4. Cluster-admin controls — a brief subsection on the kagenti-feature-gates ConfigMap (globalEnabled, injectTools, per-sidecar gates).

Cross-references the operator's webhook source so future changes to the precedence chain stay in sync.

Test plan

  • Markdown renders cleanly (tables, code blocks, links).
  • Pre-commit hooks pass (make lint, secret detection, attribution).
  • Spot-checked label defaults against kagenti-operator/internal/webhook/injector/pod_mutator.go (SpireEnableLabel, AuthBridgeInjectLabel) and precedence.go (evaluateSpiffeHelper, evaluateSidecar) at v0.2.0-rc.5.
  • Verified the table's "Helm defaults" row by inspecting a live cluster: kubectl get pod -n team1 -l app.kubernetes.io/name=weather-service -o jsonpath='{.items[0].spec.containers[*].name}' returns agent envoy-proxy spiffe-helper with the default Helm install.

Fixes #1775

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Solid, well-sourced doc, Mariusz — you even tracked down precedence.go and nailed the tricky kagenti.io/spire "layer 7" label. Dobra robota! 👏 I verified every label, the opt-out semantics, and the ConfigMap name/namespace/key against the live kagenti-operator source — all correct.

One blocker before merge: the feature-gates YAML example invents three keys that don't exist in the operator (spiffeHelper, clientRegistration, combinedSidecar) and omits the two real ones (perWorkloadConfigResolution, skillImageVolumes). For a page that markets itself as "sourced directly from the production paths, so it stays consistent with reality"... mamma mia, that phantom spiffeHelper kill switch has to go. 😄 Two small suggestions alongside it. Fix the gate list and this is an easy approve. 🟢

Areas reviewed: Docs (accuracy vs kagenti-operator source), commit/PR conventions, CI
Commits: 1, signed-off: yes
CI status: all green

globalEnabled: true # kill switch — false disables ALL injection
injectTools: false # tool workloads are not injected by default
envoyProxy: true # per-sidecar enable
spiffeHelper: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 must-fix — these keys don't exist in the operator. The real FeatureGates struct (internal/webhook/config/feature_gates.go) and the chart (charts/kagenti-operator/values.yaml) ship exactly:

globalEnabled, envoyProxy, injectTools, perWorkloadConfigResolution, skillImageVolumes
  • spiffeHelper — not a gate at all. spiffe-helper is controlled by the kagenti.io/spire label + the SPIRE_ENABLED env var (the struct comment says so explicitly). spiffeHelper: false here is a silent no-op — an admin would think they have a kill switch and they don't.
  • clientRegistration / combinedSidecar — no such keys exist.

Also missing the two real gates perWorkloadConfigResolution and skillImageVolumes. Swap in the real five and we're golden.

| `kagenti.io/spire` | (allow) | Set to `disabled` to skip `spiffe-helper` (no SPIFFE identity / JWT-SVID for this workload). |
| `kagenti.io/envoy-proxy-inject` | (allow) | Set to `false` to skip `envoy-proxy` (and the `proxy-init` init container) in envoy-sidecar mode. |
| `kagenti.io/spiffe-helper-inject` | (allow) | Set to `false` to skip the `spiffe-helper` sidecar. |
| `kagenti.io/client-registration-inject` | (skip) | Set to `true` to opt back into the legacy in-pod client-registration sidecar. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — small accuracy nit on what this label actually does. Per internal/clientreg/names.go (SkipReason), client-registration-inject=true doesn't inject anything — it tells the operator to stand down from operator-managed registration (the in-pod decision struct dropped client-registration entirely; nothing injects a sidecar). "opt back into the legacy in-pod sidecar" / "can still be requested" (also the intro paragraph ~line 83) overstates it.

Suggest: "disables operator-managed registration for this workload (for workloads that supply their own legacy registration)."

combinedSidecar: false
```

Workload-level labels are evaluated against these gates: a sidecar is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — true for envoy-proxy, but spiffe-helper has no cluster feature gate (only the kagenti.io/spire label + SPIRE_ENABLED; see precedence.go evaluateSpiffeHelper, which skips the feature-gate layer). "both the cluster gate and the workload label" doesn't hold for spiffe-helper. Once the gate list above is fixed, worth noting envoy-proxy is the only per-sidecar cluster gate.

@mrsabath
mrsabath changed the base branch from main to release-0.6 June 2, 2026 17:35
@mrsabath

mrsabath commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

@huang195 you're right — the doc is sourced against kagenti-operator v0.2.0-rc.5 (the 0.6 line). On main/0.7 the world is different: spiffe-helper is bundled into the combined image (gated by SPIRE_ENABLED), combinedSidecar and clientRegistration are no longer feature gates, and mode resolution moved to AgentRuntime.Spec.AuthBridgeMode → namespace ConfigMap → proxy-sidecar fallback (kagenti-operator#361, kagenti-extensions#409, kagenti-extensions#432).

Going with your suggestion plus a follow-up:

  1. Retargeted this PR's base to release-0.6 so the content lands where it's accurate. I'll need to rebase the branch onto release-0.6 locally to clear the merge conflicts before this can merge.
  2. Opened #1794 as a follow-up for a 0.7 rewrite on main that drops spiffeHelper/combinedSidecar/clientRegistration references, documents SPIRE_ENABLED, and uses the new mode resolution chain instead of feature gates.
  3. Cross-referenced this PR in the parent epic (#1428) under the docs/Phase C row.

Does that work for you?

Add a "Verifying and Tuning Sidecar Injection" section to deployment-guide.md
covering:

- A kubectl one-liner to inspect a pod's containers and injection labels
- A "containers per mode + label combination" table answering the
  recurring "why am I seeing 3/3 instead of 2/2?" question
- The current opt-out label vocabulary (kagenti.io/inject,
  kagenti.io/spire, kagenti.io/envoy-proxy-inject,
  kagenti.io/spiffe-helper-inject, kagenti.io/client-registration-inject)
  with defaults and effects, sourced from kagenti-operator's pod_mutator.go
  and precedence.go
- The cluster-admin feature-gates ConfigMap (globalEnabled, injectTools,
  per-sidecar gates) so cluster operators can find the global controls

Mode coverage (proxy-sidecar / envoy-sidecar / waypoint) and configuration
reference are unchanged.

Fixes #1775

Signed-off-by: Mariusz Sabath <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>
@mrsabath
mrsabath force-pushed the docs/authbridge-injection-modes branch from 4b3d96d to 8f109a0 Compare June 2, 2026 17:42
@mrsabath

mrsabath commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

@huang195 thanks for the careful read — 一针见血 (yī zhēn jiàn xiě, "one needle, sees blood" → straight to the point). You saved this PR from landing on main and confusing every 0.7 reader.

Quick status:

  • Rebased onto release-0.6 — branch now contains a single docs commit (8f109a09) on top of release-0.6. PR is MERGEABLE, ready when you are.
  • #1794 opened for the 0.7 rewrite on main with a 0.6→0.7 divergence table covering all four points you raised (spiffe-helper bundling, dropped combinedSidecar/clientRegistration/spiffeHelper gates, new mode resolution chain).
  • Epic #1428 updated to reference both this PR and docs(authbridge): rewrite sidecar injection guide for 0.7 (main) #1794 under a Documentation row.

For completeness, I weighed three other paths before going with yours: (1) one combined doc with 0.6/0.7 columns on main — discoverable but ages poorly as the lines diverge further; (2) hold this PR until 0.7 stabilizes — leaves 0.6 users without docs they need today; (3) target an RC tag instead of the branch — RCs are tagged off release-0.6 so the branch is the right home. Two-PR was the cleanest. 殊途同归 (shū tú tóng guī, "different paths, same destination").

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction — this supersedes my earlier CHANGES_REQUESTED

Mariusz, the apology is mine — my previous review was wrong, and the mistake was a good one to catch. 🙇 I verified the feature-gate keys against kagenti-operator main, but this PR targets release-0.6, which pins operator v0.2.0-rc.6. On main, spiffeHelper / clientRegistration / combinedSidecar were removed; at v0.2.0-rc.6 they all still exist:

// internal/webhook/config/feature_gates.go @ v0.2.0-rc.6
type FeatureGates struct {
    GlobalEnabled, EnvoyProxy, SpiffeHelper, ClientRegistration,
    InjectTools, PerWorkloadConfigResolution, CombinedSidecar bool
}
// DefaultFeatureGates: SpiffeHelper/ClientRegistration default true, CombinedSidecar false

So for this branch everything in the doc checks out:

  • Feature-gate YAML — spiffeHelper, clientRegistration, combinedSidecar are all real gates at rc.6. ✅ (Only perWorkloadConfigResolution is omitted from the example — fine for an illustrative admin snippet.)
  • client-registration-inject=true — precedence.go's evaluateClientRegistration opts into the legacy in-pod sidecar, exactly as the doc says. ✅
  • "both the cluster gate and the workload label" — at rc.6 spiffe-helper is feature-gated (evaluateSidecar("spiffe-helper", featureGates.SpiffeHelper, …)), so the statement holds. ✅
  • Labels, opt-out semantics, ConfigMap name/namespace/key — already verified, unchanged.

Dobra robota — the doc is accurate for release-0.6. Disregard my earlier comments; they applied to main, not this branch.

Areas reviewed: docs accuracy vs kagenti-operator v0.2.0-rc.6 (the release-0.6-pinned version), commit/PR conventions, CI
Commits: 1, signed-off: yes
CI status: green at last check

@huang195
huang195 merged commit 2e4a943 into rossoctl:release-0.6 Jun 2, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from New /:ToDo to Done in Rossoctl Issue Prioritization Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

docs(authbridge): document sidecar injection modes and label model

2 participants