Conversation
|
Welcome @aiqubits! |
|
Hi @aiqubits. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: aiqubits The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| childIndent + `{{- end }}`, | ||
| childIndent + `{{- else }}`, | ||
| childIndent + "[]", | ||
| childIndent + `{{- end }}`, |
There was a problem hiding this comment.
Would be possible to use buf.WriteString ??
Or constants as we do on other places to faciliate the maintainability?
There was a problem hiding this comment.
Updated. The shared Helm condition is now a named constant, and the block is generated with strings.Builder. The existing-env and optional-env paths share the same builder while preserving their different default rendering behavior.
| ## Environment variable overrides (--set manager.envOverrides.VAR=value) | ||
| ## These values take precedence over entries with the same name in manager.env. | ||
| ## | ||
| envOverrides: {} |
There was a problem hiding this comment.
Why that was added ??
Would with this propose we start to add it indeed when has no ENV VARs?
What would be the use cases?
Pros and cons? Maybe that is the right approach just trying to think on that to ensure that we are going in the right direction.
There was a problem hiding this comment.
I added this because the workaround in #5987 currently does not work for the common case where the source Deployment has no env field: both the generated env template and envOverrides are omitted.
However, you are right that always exposing envOverrides broadens the chart API beyond what this fix needs. Helm can create a missing nested value through --set, so I can narrow the change: keep envOverrides in values.yaml only when source env entries exist, while generating a fully conditional env block for deployments without env. The default manifest then remains unchanged, but the explicit --set manager.envOverrides.ENABLE_WEBHOOKS=false workaround still works.
Always expose manager.envOverrides and template the manager env field even when the source Deployment has no environment variables. Document the limits of webhook.enabled and the conversion webhook caveat.
3d058bd to
e3e2825
Compare
|
One wording point on the new aside, since it is going into the book as a permanent warning.
That holds today for two independent reasons: the chart does not pass The second reason is already gone upstream. controller-runtime#3481 (merged 2026-07-27, unreleased, newest tag is v0.24.1 from 2026-05-12) narrowed that to Scoping it to what we pin would keep it accurate, something like: "with the controller-runtime version the scaffold currently pins, no |
|
@hexbinoct I scoped the statement to the controller-runtime version currently pinned by the scaffold, as suggested. Thanks for catching that. |
|
Hi @aiqubits See the comment: #5987 (comment) We will need to bump controller-runtime latest and then address this one |
There was a problem hiding this comment.
馃煝 Approval recommended
The implementation preserves default rendering while providing tested, documented opt-out behavior.
Pull request overview
Adds explicit Helm environment overrides so users can disable scaffolded webhook registration without changing default chart output.
Changes:
- Conditionally renders manager environment overrides when no source
envfield exists. - Adds unit and integration coverage for default and override rendering.
- Documents webhook opt-out behavior and regenerates tutorial charts.
File summaries
| File | Description |
|---|---|
pkg/plugins/optional/helm/v2alpha/scaffolds/test/chart_generation_integration_test.go |
Tests rendered override behavior. |
pkg/plugins/optional/helm/v2alpha/scaffolds/internal/templates/values_test.go |
Tests environment values generation. |
pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/templater/appliers/manager.go |
Adds conditional manager environment templating. |
pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/templater/appliers/helpers_test.go |
Covers env-less and inline-env deployments. |
docs/book/src/plugins/available/helm-v2-alpha.md |
Documents webhook behavior and opt-out usage. |
docs/book/src/multiversion-tutorial/testdata/project/dist/chart/templates/manager/manager.yaml |
Regenerates the multiversion chart. |
docs/book/src/getting-started/testdata/project/dist/chart/templates/manager/manager.yaml |
Regenerates the getting-started chart. |
docs/book/src/cronjob-tutorial/testdata/project/dist/chart/templates/manager/manager.yaml |
Regenerates the CronJob chart. |
Review details
- Files reviewed: 5/8 changed files
- Comments generated: 0
- Review effort level: Balanced
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| Setting `webhook.enabled=false` prevents the chart from rendering the webhook `Service`, admission webhook configurations, and `NetworkPolicy`. It does not prevent the scaffolded manager from registering its webhooks or starting its webhook server. | ||
|
|
||
| When `webhook.enabled=false`, the chart does not pass `--webhook-port` to the manager. The scaffolded manager therefore listens on its compiled default port, `9443`, regardless of `webhook.port`. The `Deployment` still declares `webhook.port` as the `webhook-server` container port, but this declaration does not configure the listener. With the controller-runtime version the scaffold currently pins, no `webhook.port` value disables the server. |
There was a problem hiding this comment.
@aiqubits could you please check in the latets CR release if we cannot set 0 as it is done for metrics?
There was a problem hiding this comment.
@camilamacedo86 I checked controller-runtime v0.25.0. Port 0 still defaults to 9443, while Port -1 disables the webhook server: https://github.com/kubernetes-sigs/controller-runtime/blob/v0.25.0/pkg/webhook/server.go#L76-L80 and https://github.com/kubernetes-sigs/controller-runtime/blob/v0.25.0/pkg/webhook/server.go#L203-L206.
Kubebuilder still pins v0.24.1, so after the controller-runtime bump lands I will revise this PR to use --webhook-port=-1 and remove the envOverrides workaround.
|
@camilamacedo86 I confirmed that controller-runtime v0.25.0 supports disabling the webhook server with Port: -1. I agree that the version bump should land first; afterward, I will rework this PR to use --webhook-port=-1 and remove the envOverrides workaround. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description
webhook.enabled=falseskips the webhook resources rendered by the chart, but it does not stop the scaffolded manager from registering webhooks or starting its webhook server.This change:
manager.envOverrides.ENABLE_WEBHOOKS=falsewebhook.enabledbehavior, the default9443listener, and conversion webhook limitationsThe chart does not automatically set
ENABLE_WEBHOOKS=false, so existing runtime behavior remains unchanged unless the user explicitly configures the override.Fixes #5987
Testing
make test-unitgo test -race -tags=integration -timeout 10m ./pkg/plugins/optional/helm/v2alpha/...make generate-chartsmake helm-lintmake kube-lintermake fix-docsbin/golangci-lint fmt --diffmanager.envOverrides.ENABLE_WEBHOOKS=falseand verified that Helm emitsvalue: "false"