Repository navigation
fix(chart): the controller's webhook RBAC follows the condition that renders the webhook (#1411) - #1426
Merged
Conversation
…renders the webhook (#1411) controller-webhook.yaml rendered the MutatingWebhookConfiguration, and controller-deployment.yaml passed --mutating-webhook-config-name, when either controller.namespaceInjection or controller.injectPodNdots was on. controller-rbac.yaml granted mutatingwebhookconfigurations under injectPodNdots alone. With controller.webhook.spire=true, namespaceInjection=true and injectPodNdots=false the controller was told to fill in the caBundle of an object it had no permission to read. The condition is now one helper, aether.controller.mutatingWebhook, read by all three templates; the object's name is one helper too. Eight template tests render {SPIRE-served webhook} x {namespaceInjection} x {injectPodNdots} and check that the object, the flag and the grant agree in every cell. One of them failed against the unchanged chart (the affected cell); the other seven are guards. The render is byte-identical to 2.4.17 in every cell except that one, which gains the ClusterRole rule. No pod template changes. Chart 2.4.18. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🟢 Approval recommended
The shared condition resolves the RBAC mismatch and comprehensive render tests cover every configuration combination.
0 open findings
What changed in this PR
Centralizes the pod-mutating webhook condition so rendering, controller arguments, and SPIRE RBAC remain consistent.
Changes:
- Adds shared helpers for webhook existence and naming.
- Fixes RBAC for namespace-injection-only deployments.
- Adds an eight-cell render truth table and operational documentation.
| File | Description |
|---|---|
charts/aether/templates/_helpers.tpl |
Defines shared webhook helpers. |
charts/aether/templates/controller-webhook.yaml |
Uses shared rendering and naming logic. |
charts/aether/templates/controller-deployment.yaml |
Uses shared condition for the controller flag. |
charts/aether/templates/controller-rbac.yaml |
Grants RBAC whenever the webhook renders. |
charts/aether/BUILD.bazel |
Tests all relevant configuration combinations. |
charts/aether/Chart.yaml |
Bumps the chart to 2.4.18. |
charts/aether/values.yaml |
Documents conditional SPIRE RBAC. |
docs/configuration.md |
Updates webhook configuration guidance. |
docs/runbook.md |
Adds diagnosis and recovery instructions. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
This was referenced Oct 8, 2026
Closed
There was a problem hiding this comment.
🟢 Approval recommended
The shared condition resolves the RBAC mismatch and is comprehensively covered across all configuration combinations.
0 open findings
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
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.
Closes #1411
This pull request was written by an agent (Claude Code). It fixes #1411. It does not change anything for #1412 and does not close it: see "About #1412" below for why, and for what the owner needs to decide.
The bug (#1411)
Three things depend on "the pod-mutating webhook exists":
controller-webhook.yamlMutatingWebhookConfigurationnamespaceInjectionORinjectPodNdotscontroller-deployment.yaml--mutating-webhook-config-name(SPIRE-served webhook only)namespaceInjectionORinjectPodNdotscontroller-rbac.yamlmutatingwebhookconfigurations(SPIRE-served webhook only)injectPodNdotsaloneWith
controller.webhook.spire=true,namespaceInjection=true,injectPodNdots=falsethe controller was told to fill in thecaBundleof an object it had no permission to read.The fix
One helper,
aether.controller.mutatingWebhook(_helpers.tpl), read by all three templates. A second helper,aether.controller.mutatingWebhookName, gives the object and the flag the same name from one place (the rendered name is unchanged).I looked for anything else gated on the same fact. There is nothing else in the chart. The identity-gate flags (
--identity-gate=…) are gated onspire.enabledandcontroller.webhook.identityGate.enabled, not on the webhook existing; with both switches off they are passed and are inert, because nothing routes a pod to/mutate. I left that as it is on purpose: making them follow the helper would change the controller's pod template (and roll it) for a release with both switches off, with no change in behaviour.Truth table, rendered (
helm template, helm v3.18.4)config= theMutatingWebhookConfigurationrenders;flag=--mutating-webhook-config-nameis passed;rbac= the ClusterRole grantsmutatingwebhookconfigurations. The flag and the grant are expected exactly when the webhook is SPIRE-served and the configuration renders.Before (chart 2.4.17):
After (this branch):
Render diff, before and after
All eight cells plus the default render, certificate lines masked as
docs/runbook.md("Rendering the chart reproducibly") describes. Every differing line, counted over the nine renders:Before the version bump the nine renders were byte-identical to
mainexcept the affected cell, whose only difference was those three rule lines inClusterRole/<release>-aether-controller-<namespace>.What an upgrade does
controller.injectPodNdots=true, or with the self-signed webhook: nothing but thehelm.sh/chartlabel on each object, as with any chart release. That label is on object metadata, not in any pod template.controller.webhook.spire=true+namespaceInjection=true+injectPodNdots=false: the controller's ClusterRole gains one rule. Nothing else.//charts/aether:aether_pod_template_version_testand its siblings also pass.What happens at runtime without the rule (read from the code, not reproduced)
I read
controller/internal/meshconfig/cabundle.go,controller/internal/cmd/root.go,common/manager, and controller-runtime v0.25.2's cache. No Go is changed here.Geton the mutating one through the manager's client, which reads from the informer cache.Getstarts an informer forMutatingWebhookConfiguration. Withoutlist/watchthe informer never syncs, and a cachedGetwaits for the sync with no timeout. So the call does not fail: it never returns. The injector's own error line (webhook caBundle injection failed) is never logged. The only log signal is client-go's reflector reporting the forbidden list, repeatedly.caBundleis written once and not refreshed when the SPIRE trust bundle rotates, for as long as that leader lives.cache-syncreadiness check waits on every informer, including this one, so the leader replica should go NotReady and leave the webhook Service's endpoints. The second replica (defaultreplicaCount: 2) keeps serving.caBundlestays empty; the apiserver cannot verify the controller, and withfailurePolicy: Ignorenamespace injection and the identity gate are skipped silently, as the issue says.I could not verify this on a cluster: it needs SPIRE issuing the controller an SVID, and the task was to read. Treat the four runtime points as inferred.
Tests, red first
Eight new targets in
charts/aether/BUILD.bazel, one per cell (helm_template_match_testwithdocument_patternsfor the cells where the configuration renders with the SPIRE-served webhook;helm_template_absent_testfor the others). Against the unchanged chart:One is red (the affected cell); the other seven are guards for behaviour that must not change. After the fix:
bazel test //charts/... //bazel/helm/..., 186 of 186 pass.Also run:
bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...andmake format-check, both clean. The remote cache was unreachable for part of the session ("Failed to query remote execution capabilities: UNAVAILABLE"), so the final test and lint runs were local, with the remote cache flags emptied on the command line.Docs
docs/runbook.md: "The pod-mutating webhook's caBundle is empty (SPIRE-served webhook, chart: with the SPIRE-served webhook, namespaceInjection on and injectPodNdots off, the controller has no RBAC to patch the mutating webhook's caBundle #1411)", with the two commands that measure it on a cluster (kubectl auth can-ifor the controller's ServiceAccount, and thecaBundlelength of every webhook entry).docs/configuration.mdandvalues.yaml: thecontroller.webhook.spirerow and comment say what the controller is granted.About #1412 (
controller.webhook.spire=truewithspire.enabled=false)The issue asks to fail the render for this pair. I did not, because what I read says the pair is a working configuration rather than a contradiction, and failing it would break it:
values.yaml, the header ofcontroller-webhook.yamlanddocs/configuration.mdall describe the webhook certificate source as decoupled from mesh SPIRE.values.yamldescribesspire.enabledas "the mesh-wide mTLS switch", not as "SPIRE is installed".controller.webhook.spirealone: the flag, the socket path, thecsi.spiffe.iovolume, theClusterSPIFFEID, the RBAC, and no Secret. Withspire.enabled=falsethe render is coherent: only the controller uses SPIRE, and it is passed--identity-gate=false.--spire-enabledmeans only "serve the webhook with an SVID and inject the bundle". It has no mesh meaning.helm template(Argo CD) to serve the webhook with SPIRE, because the self-signed path generates a new CA on every sync. With a render failure, such an operator running the mesh without mTLS would have no stable webhook certificate at all. The runbook's "render both sides with--set controller.webhook.spire=true" way of diffing would also stop working for any values file withspire.enabled=false.webhook.spire=trueon a cluster with no SPIRE.spire.enableddoes not tell the chart that, and the same mistake is possible withspire.enabled=true.Against that: #231, which introduced the value, was about the other direction (mesh SPIRE on, self-signed webhook); one template comment (
agent-proxy-daemonset.yaml) treatsspire.enabled=falseas "SPIRE is not deployed"; and nothing in the repository uses the pair. So this is the owner's call. Ifspire.enabled=falseis meant to say "there is no SPIRE in this cluster", the failure is a small follow-up; if not, the issue is better closed with a sentence invalues.yamlsaying the pair is supported and a test that pins it.On the test guard from #1410: no
helm_template_testincharts/aether/BUILD.bazelsetsspire.enabled=false. The only test that does isaether_identity_gate_no_spire_test, on the masked rule. Its comment says the pair "cannot be rendered"; today it can.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr