Skip to content

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Oct 27, 2025

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 27, 2025
@camilamacedo86 camilamacedo86 force-pushed the args-helm branch 2 times, most recently from 515ab8b to 4b381d1 Compare October 27, 2025 13:30
tag: latest
pullPolicy: IfNotPresent

# Arguments for the manager
Copy link
Member Author

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.

@camilamacedo86 camilamacedo86 changed the title ✨ (helm/v2alpha): ensure that args are obtained and used in the helm charts WIP: ✨ (helm/v2alpha): ensure that args are obtained and used in the helm charts Oct 27, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2025
@camilamacedo86 camilamacedo86 force-pushed the args-helm branch 2 times, most recently from a328ed7 to ff241c8 Compare October 28, 2025 08:53
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2025
@camilamacedo86 camilamacedo86 changed the title WIP: ✨ (helm/v2alpha): ensure that args are obtained and used in the helm charts 🐛 (helm/v2alpha): ensure properly customization of the manager values Oct 28, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 28, 2025
@camilamacedo86 camilamacedo86 changed the title 🐛 (helm/v2alpha): ensure properly customization of the manager values 🐛 (helm/v2alpha): ensure properly customization of the manager values ( follow up implementation of helm/v2alpha ) Oct 28, 2025
@camilamacedo86 camilamacedo86 changed the title 🐛 (helm/v2alpha): ensure properly customization of the manager values ( follow up implementation of helm/v2alpha ) 🐛 (helm/v2alpha): ensure properly customization of the manager values ( follow up implementation of helm/v2alpha ) Oct 28, 2025
@camilamacedo86
Copy link
Member Author

/override pull-kubebuilder-e2e-k8s-1-34-1

@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • pull-kubebuilder-e2e-k8s-1-34-1

Only the following failed contexts/checkruns were expected:

  • EasyCLA
  • netlify/kubebuilder/deploy-preview
  • pull-kubebuilder-e2e-k8s-1-32-0
  • pull-kubebuilder-e2e-k8s-1-33-0
  • pull-kubebuilder-e2e-k8s-1-34-0
  • pull-kubebuilder-test
  • tide

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:

/override pull-kubebuilder-e2e-k8s-1-34-1

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.

@camilamacedo86 camilamacedo86 force-pushed the args-helm branch 2 times, most recently from 5cff21e to 6d2155a Compare October 28, 2025 10:25
@camilamacedo86 camilamacedo86 changed the title 🐛 (helm/v2alpha): ensure properly customization of the manager values ( follow up implementation of helm/v2alpha ) 🐛 (helm/v2alpha): (helm/v2alpha): allow manager values to be customized properly Oct 28, 2025
@camilamacedo86
Copy link
Member Author

/override pull-kubebuilder-e2e-k8s-1-34-0

@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0

In response to this:

/override pull-kubebuilder-e2e-k8s-1-34-0

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.

@camilamacedo86 camilamacedo86 changed the title 🐛 (helm/v2alpha): (helm/v2alpha): allow manager values to be customized properly 🐛 (helm/v2alpha): allow manager values to be customized properly Oct 28, 2025
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
@camilamacedo86
Copy link
Member Author

/override pull-kubebuilder-e2e-k8s-1-34-0

@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0

In response to this:

/override pull-kubebuilder-e2e-k8s-1-34-0

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.

@camilamacedo86
Copy link
Member Author

/override pull-kubebuilder-e2e-k8s-1-34-0

@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-34-0

In response to this:

/override pull-kubebuilder-e2e-k8s-1-34-0

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 }}
- {{ . }}
Copy link
Member Author

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
Copy link
Member Author

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 }}
Copy link
Member Author

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 }}
Copy link
Member Author

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 }}
Copy link
Member Author

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)
Copy link
Member Author

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 camilamacedo86 added this to the helm milestone Oct 28, 2025
@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubebuilder-e2e-k8s-1-32-0 1966560 link true /test pull-kubebuilder-e2e-k8s-1-32-0

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.

Copy link
Contributor

@liam-mackie liam-mackie left a 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- --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

Copy link
Member Author

Choose a reason for hiding this comment

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

Amazing cather. Yes

Comment on lines +189 to 198
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:]
}
}
Copy link
Contributor

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

Copy link
Member Author

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.

Comment on lines +566 to +569
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)
Copy link
Contributor

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"))
Copy link
Contributor

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") {
Copy link
Contributor

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?

Copy link
Member Author

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() {
Copy link
Contributor

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?

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@liam-mackie
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@liam-mackie: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

Copy link

Copilot AI left a 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-elect as 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, " ")
Copy link

Copilot AI Oct 28, 2025

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.

Suggested change
trimmed := strings.TrimLeft(line, " ")
trimmed := strings.TrimLeft(line, " \t")

Copilot uses AI. Check for mistakes.
}

// The following arguments should not be exposed under args
// manager because they are not alone customizable
Copy link

Copilot AI Oct 28, 2025

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'.

Suggested change
// manager because they are not alone customizable
// manager because they are not independently customizable

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-blocker size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants