-
Couldn't load subscription status.
- Fork 1.6k
🐛 (helm/v2alpha): allow manager values to be customized properly #5147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
515ab8b to
4b381d1
Compare
| tag: latest | ||
| pullPolicy: IfNotPresent | ||
|
|
||
| # Arguments for the manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Use only Arguments instead to match with ENVVAR too.
a328ed7 to
ff241c8
Compare
6596011 to
77cd6bb
Compare
|
/override pull-kubebuilder-e2e-k8s-1-34-1 |
|
@camilamacedo86: /override requires failed status contexts, check run or a prowjob name to operate on.
Only the following failed contexts/checkruns were expected:
If you are trying to override a checkrun that has a space in it, you must put a double quote on the context. In response to this:
Instructions 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. |
5cff21e to
6d2155a
Compare
6d2155a to
62d91f9
Compare
|
/override pull-kubebuilder-e2e-k8s-1-34-0 |
|
@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0 In response to this:
Instructions 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. |
This update makes sure the manager Helm chart uses values taken from the Kustomize deployment files (like install.yaml), instead of using hardcoded settings. The controller specs are now read from those inputs and passed into Helm values so the chart renders correctly and matches the deployment. PS:Follow up of helm-chart v2alpha introduction Assisted-by: Cursor
62d91f9 to
1966560
Compare
|
/override pull-kubebuilder-e2e-k8s-1-34-0 |
|
@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0 In response to this:
Instructions 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. |
|
/override pull-kubebuilder-e2e-k8s-1-34-0 |
|
@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0 In response to this:
Instructions 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. |
| {{- end }} | ||
| - --health-probe-bind-address=:8081 | ||
| {{- range .Values.controllerManager.args }} | ||
| - {{ . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that we have the possible args exposed now
| - --leader-elect | ||
| {{- else }} | ||
| # Bind to :0 to disable the controller-runtime managed metrics server | ||
| - --metrics-bind-address=:0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that we properly disable the metrics server in c+r when it is not enabled
(more safe)
| command: | ||
| - /manager | ||
| image: "{{ .Values.controllerManager.image.repository }}:{{ .Values.controllerManager.image.tag }}" | ||
| imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting from the helm values it was missing
| {{- toYaml .Values.controllerManager.securityContext | nindent 20 }} | ||
| {{- else }} | ||
| {} | ||
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting from helm values it was missing
| {{- toYaml .Values.controllerManager.podSecurityContext | nindent 14 }} | ||
| {{- else }} | ||
| {} | ||
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting from helm values it was missing
| extractContainerImage(container, config) | ||
| extractContainerArgs(container, config) | ||
| extractContainerResources(container, config) | ||
| extractContainerSecurityContext(container, config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we ensure that we extract all values from the manager in the kustomize input.
|
@camilamacedo86: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions 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. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Amazing work!
Some minor nits/comments, but they can be ignored if my understanding is incorrect.
I wish there was a better option than all the string and indentation manipulation we need to do when modifying the yaml string, but I guess that's yaml 🤷
| - --leader-elect | ||
| {{- else }} | ||
| # Bind to :0 to disable the controller-runtime managed metrics server | ||
| - --metrics-bind-address=:0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - --metrics-bind-address=:0 | |
| - --metrics-bind-address=0 |
Though I assume that this is sourced from templates later on in the PR, I believe that the bind address should be 0 instead of :0 based on the metrics-server code here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing cather. Yes
| repository := imageValue | ||
| tag := "latest" | ||
| lastColon := strings.LastIndex(imageValue, ":") | ||
| lastSlash := strings.LastIndex(imageValue, "/") | ||
| if lastColon != -1 && lastColon > lastSlash { | ||
| repository = imageValue[:lastColon] | ||
| if lastColon+1 < len(imageValue) { | ||
| tag = imageValue[lastColon+1:] | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Consider using the parser package implementation if we're safe to include the utils package as a dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to avoid add deps as much as possible to reduce the burn to keep things maintained.
| builder.WriteString("# Bind to :0 to disable the controller-runtime managed metrics server\n") | ||
| builder.WriteString(metricsIndent) | ||
| builder.WriteString("- --metrics-bind-address=:0\n") | ||
| builder.WriteString(metricsIndent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented in the docs - we should bind to 0 instead to disable I think
| Expect(result).To(ContainSubstring("- --health-probe-bind-address=:8081")) | ||
| Expect(result).To(ContainSubstring("{{- range .Values.controllerManager.args }}")) | ||
| Expect(result).NotTo(ContainSubstring("BUSYBOX_IMAGE")) | ||
| Expect(result).NotTo(ContainSubstring("MEMCACHED_IMAGE")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be in the source spec, so this should always evaluate to true.
| } | ||
| return match | ||
| }) | ||
| if !strings.Contains(yamlContent, "name: manager") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, this means that we only allow the values.yaml to be used to specify the manager container image. If there are any sidecar/init containers, etc, we will keep the image as templated in Kustomize.
Is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. If there are any sidecar/init containers, etc, we will keep the image as templated in Kustomize.
Is that expected?
We do not scaffold any sidecar and etc.
Then, those are customisations made on top.
For it users will need to tweak things afterwards manually. |
We cannot support all possible scenarios.
However, if anyone be able to improve it to accept more scenarios, I am ok with it.
| Expect(err).NotTo(HaveOccurred()) | ||
| }) | ||
|
|
||
| It("should include deployment configuration", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this include assertions for the env variables we set?
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, liam-mackie The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
@liam-mackie: changing LGTM is restricted to collaborators In response to this:
Instructions 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables proper customization of Helm chart values by extracting controller manager configuration from Kustomize deployment files rather than using hardcoded values. The changes ensure the Helm chart templates correctly reference values.yaml for container image, arguments, environment variables, resources, and security contexts.
Key Changes
- Extract deployment configuration (image, args, env, resources, security contexts) from Kustomize output
- Template manager.yaml to use
.Values.controllerManager.*references instead of hardcoded values - Add args section to values.yaml with
--leader-electas default
Reviewed Changes
Copilot reviewed 6 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/chart_converter.go | Refactored extraction logic to parse image info, args, env, resources, and security contexts from deployment |
| pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/helm_templater.go | Added templating functions for args, env, resources, security contexts, and image references |
| pkg/plugins/optional/helm/v2alpha/scaffolds/internal/templates/values_basic.go | Enhanced values generation to include image config and args section from deployment config |
| testdata/project-v4-with-plugins/dist/chart/templates/manager/manager.yaml | Converted hardcoded values to Helm template references |
| testdata/project-v4-with-plugins/dist/chart/values.yaml | Added args section with leader-elect flag |
| Multiple test files | Updated tests to verify new extraction and templating behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| func leadingWhitespace(line string) (string, int) { | ||
| trimmed := strings.TrimLeft(line, " ") |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tab character is represented as a literal whitespace character instead of using an escape sequence. This should be \" \\t\" for better readability and consistency with the rest of the codebase.
| trimmed := strings.TrimLeft(line, " ") | |
| trimmed := strings.TrimLeft(line, " \t") |
| } | ||
|
|
||
| // The following arguments should not be exposed under args | ||
| // manager because they are not alone customizable |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment contains a grammatical error. 'not alone customizable' should be 'not independently customizable' or 'cannot be customized independently'.
| // manager because they are not alone customizable | |
| // manager because they are not independently customizable |
This update makes sure the manager Helm chart uses values taken from the
Kustomize deployment files (like install.yaml), instead of using hardcoded
settings. The controller specs are now read from those inputs and passed
into Helm values so the chart renders correctly and matches the deployment.
PS:Follow up of helm-chart v2alpha introduction
Closes; #5114 #5113