Repository navigation
fix(chart): the webhook certificate is reused, replaced only when incomplete or rotated; helm template's exception is documented (#1364) - #1368
Conversation
04e38be to
0323b77
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Certificate rotation has a trust-ordering race, and test diagnostics can expose generated secrets.
2 open findings
What changed in this PR
Adds reusable webhook certificates, explicit rotation, and documentation for nondeterministic offline Helm renders.
Changes:
- Regenerates incomplete certificates and supports token-based rotation.
- Adds reproducibility tests with certificate masking.
- Documents rendering, verification, and rotation procedures.
| File | Description |
|---|---|
docs/runbook.md |
Documents reproducible rendering and rotation. |
docs/configuration.md |
Documents webhook settings. |
charts/aether/values.yaml |
Adds certRotation. |
charts/aether/templates/controller-webhook.yaml |
Implements reuse and rotation. |
charts/aether/Chart.yaml |
Bumps chart version. |
charts/aether/BUILD.bazel |
Adds chart tests. |
bazel/helm/defs.bzl |
Adds reproducibility test rule. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0323b77 to
ca5cdaf
Compare
ca5cdaf to
74ac71f
Compare
74ac71f to
b756355
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Clearing the rotation token loses its idempotency stamp, allowing the same token to rotate certificates again.
1 open finding
2 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
b756355 to
a66635b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The cluster-dependent certificate reuse and rotation branches lack automated coverage.
1 open finding
1 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
…omplete or rotated; helm template's exception is documented and pinned (#1364) With controller.webhook.spire=false the chart generates a self-signed webhook CA and serving certificate. An upgrade already reused the Secret it found (lookup), so a real upgrade changed neither the Secret's data nor a caBundle. A render without a cluster cannot look anything up and generates a new pair every time: six lines of `helm template` differ between two renders. - The reuse is stated and hardened: a Secret with an empty or missing ca.crt, tls.crt or tls.key is replaced. Before, an empty tls.key made every upgrade fail ("data[tls.key]: Required value"). - controller.webhook.certRotation rotates on demand: a new value generates a new pair once and is stamped on the Secret. During that upgrade caBundle carries the new CA and the one being replaced. - helm_template_reproducible_test renders twice and compares: identical with the six certificate lines masked, and with no mask at all when controller.webhook.spire=true. A new render-time value fails it. - The runbook has the recipe for a stable diff and for rotation. Chart aether 2.4.16. No pod template changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
a66635b to
a6e613b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Certificate rotation is cluster-state-dependent, lacks automated coverage for lookup branches, and retains a documented fail-open transition window.
0 open findings
1 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.


Closes #1364
Top of a stack of two; #1367 (for #1363) is the base.
What an upgrade does today (the issue's second half is not what happens)
The issue says an upgrade rewrites the webhook secret and CA bundle each time. It does not:
controller-webhook.yamlalready looks the Secret up and reuses it.helm upgrade?main's chart and Helm 3.18.4: the data hash is the same after an upgrade to another version, a downgrade and an upgrade at a changed versioncaBundlechange with it?caBundlehash is unchangedresourceVersionchanges because thehelm.sh/chartlabel changescontroller/internal/cmd/root.goand controller-runtime v0.25.2 (pkg/webhook/server.go,pkg/certwatcher). Not exercised on a running controllerhelm template?ca.crt,tls.crt,tls.key, and threecaBundle)talos-main cannot show any of this: it runs
controller.webhook.spire=true(read withhelm get values), so there is no self-signed Secret there. The controller pods there are as old as the last deploy, which is the roll #1363 describes, not this.Reuse is safe for the current names by construction: the certificate's two SANs are
<service>.<namespace>.svc[.cluster.local]and the Secret is looked up as<service>-certin<namespace>, so another service name or namespace is another Secret. On kind the serving certificate verified against thecaBundleand carried both SANs after every step.What changes
mainreused the Secret wheneverca.crtwas present. Measured on kind: withtls.keyemptied, every upgrade ofmain's chart fails withSecret "aether-controller-webhook-cert" is invalid: data[tls.key]: Required valueuntil someone deletes the Secret. This chart generates a new pair instead.controller.webhook.certRotation(default"", never rotate). The pair is valid ten years and nothing renewed it; the only way to rotate was deleting the Secret by hand. A new value generates a new pair on the next upgrade and is stamped on the Secret (aether.io/webhook-cert-rotation); the same value, clearing it, or restoring it after clearing rotates nothing (the stamp stays on a reused Secret). A token rather than a boolean, so a value left in a GitOps repository does not rotate on every reconcile.caBundlecarries the new CA and the one being replaced, so the certificate the controller is still serving keeps verifying until it reloads. The next upgrade renders the new CA alone. Without this, every rotation opens a window in which the webhooks fail open (failurePolicy: Ignore): pods admitted then are not mutated. This narrows the window; it does not close it (raised in review): Helm patches the Secret before the webhook configurations, so a controller pod that starts in between, or an upgrade that fails in between, serves the new certificate against the oldcaBundleuntil the upgrade completes. Closing it needs the new CA trusted one upgrade before the new certificate is served; not done here, and the docs say so.helm templateis the documented exception, in the template header,values.yaml,docs/configuration.mdand a new runbook section ("Rendering the chart reproducibly") with the masking recipe, thecontroller.webhook.spire=truealternative and its limits, how to hash the certificate before and after an upgrade without printing it, and the rotation procedure.The
lookupuses incontroller-meshconfig.yamlandedge-meshconfig.yamlare deterministic (seed the MeshConfig once,resource-policy: keep); they render the same thing every time without a cluster and are left alone.No pod template changes: nothing rolls because of this PR.
Measured on kind
Kind v0.33.0, the pinned node image, Helm 3.18.4, its own kubeconfig, deleted afterwards. Only hashes, counts and metadata were printed.
caBundlecaBundlecertRotation=2026-10resourceVersiontoo)resourceVersiontoo)tls.keyemptied, then upgradeversion+appVersionchangedTests
New rule
helm_template_reproducible_test(bazel/helm/defs.bzl): renders twice and compares, with named keys masked, and fails if the mask hides a different number of lines than declared.aether_webhook_cert_rotation_stamp_test(the value is stamped on the Secret).aether_reproducible_masked_testand..._all_enabled_masked_test(identical with exactly six lines masked),aether_reproducible_webhook_spire_test(identical with no mask),aether_webhook_cert_rotation_off_test(no annotation by default),aether_webhook_cert_rotation_spire_test(no Secret with SPIRE). Mutation check: droppingcaBundlefrom the mask fails the masked test (the mask hid 3 lines, want 6).Not testable hermetically: everything behind
lookup(reuse, the incomplete-Secret branch, rotation, the two-CA bundle).helm templatehas no cluster to look in. Those are covered by the kind run above, which is not in CI.What an operator does on upgrade
Nothing. The existing Secret is reused and gains no annotation. To check, hash before and after:
Verified
bazel test //charts/... //bazel/helm/...,bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...,make format-check.Not verified
helm diffshows by default: the runbook says it needs--dry-run=serverto look the Secret up; I did not run the plugin.Noticed, not changed
helm upgradewith no value flags reuses the previous release's values (Helm 3 default), which is how acertRotation"removed" from the command line stays set.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr