Skip to content

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Aug 27, 2025

Introduce helm/v2-alpha Plugin: Dynamic Helm Chart Generation

This PR introduces a completely rewritten Helm plugin (helm/v2-alpha) that dynamically generates Helm charts based on the actual kustomize output from make build-installer, replacing the previous hardcoded template approach in helm/v1-alpha.

The existing helm/v1-alpha plugin used static templates that didn't reflect user customizations (environment variables, labels, annotations, security contexts, etc.) made in their kustomize configuration. This led to inconsistencies between kubectl apply -f dist/install.yaml and helm install.

Key Features

  • Dynamic generation: Charts generated from actual kustomize output (dist/install.yaml)
  • Smart organization: Resources split into logical directories (metrics/, webhook/, cert-manager/, rbac/, crd/)
  • Conditional logic: Only includes resources that actually exist (certManager, webhooks, metrics)
  • Individual files: CRDs, RBAC, and certificates as separate files for better maintainability
  • Enhanced values.yaml: Dynamic configuration based on detected project features

Changes

  • Deprecated Helm v1-alpha in favour of v2
  • Add docs and tests for Helm v2
  • Update all samples
  • Address all feedback raised so far

Documentation

📖 Preview docs: https://deploy-preview-5058--kubebuilder.netlify.app/plugins/available/helm-v2-alpha

How to Review

  • Documentation: Check the docs link above for complete feature overview
  • Core implementation: Focus on pkg/plugins/optional/helm/v2alpha/ for the actual code changes
  • File changes context: Most changes under testdata/ and docs/ are sample updates with helm/v2-alpha
  • Test coverage: Comprehensive unit tests added with GitHub workflow integration for e2e testing via Prow
  • Play with in your solutions 🙏

Usage

# Generate Helm chart from kustomize output
kubebuilder edit --plugins=helm.kubebuilder.io/v2-alpha

# Custom output directory  
kubebuilder edit --plugins=helm.kubebuilder.io/v2-alpha --output=charts

Closes:

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 27, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 27, 2025
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 27, 2025
@camilamacedo86 camilamacedo86 force-pushed the helm-change-manager branch 7 times, most recently from cb1ee39 to 1acfef2 Compare August 28, 2025 09:58
@camilamacedo86 camilamacedo86 changed the title WIP Add helm/v2-alpha and deprecated helm/v1-alpha ✨ Add helm/v2-alpha addressing all feedbacks and lessons learned. Deprecated helm/v1-alpha in favor of helm/v2-alpha Aug 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 Aug 28, 2025
@camilamacedo86 camilamacedo86 force-pushed the helm-change-manager branch 2 times, most recently from d9d172d to 2a5c5be Compare August 28, 2025 10:48
@camilamacedo86 camilamacedo86 changed the title ✨ Add helm/v2-alpha addressing all feedbacks and lessons learned. Deprecated helm/v1-alpha in favor of helm/v2-alpha WIP ✨ Add helm/v2-alpha addressing all feedbacks and lessons learned. Deprecated helm/v1-alpha in favor of helm/v2-alpha Aug 28, 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 Aug 28, 2025
@camilamacedo86 camilamacedo86 force-pushed the helm-change-manager branch 4 times, most recently from 8203eed to 1cb0ec1 Compare August 29, 2025 18:18
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 29, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 29, 2025
@camilamacedo86 camilamacedo86 force-pushed the helm-change-manager branch 3 times, most recently from 16b3fca to 1863d2e Compare August 31, 2025 00:57
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 14, 2025
@abhijith-darshan
Copy link

abhijith-darshan commented Sep 14, 2025

HI @abhijith-darshan

The args might be a good thought, but I think we could check this one in a follow-up, wdyt?

Sure. Once this is in, I can contribute towards enhancements as well, thanks.

For now, LGTM 🚀

@camilamacedo86
Copy link
Member Author

/retest-required

@camilamacedo86 camilamacedo86 force-pushed the helm-change-manager branch 2 times, most recently from c37628c to 99911fe Compare September 19, 2025 12:19
Comment on lines +58 to +59
return "helm/v1-alpha plugin is deprecated, use helm/v2-alpha instead which " +
"provides dynamic Helm chart generation from kustomize output"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we have a single string here instead of concatenation?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would cause the lint check lll fail

return nil
}

const helmHelpersTemplate = `{{` + "`" + `{{/*
Copy link
Contributor

Choose a reason for hiding this comment

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

for the future maintenance, would it helpful to move this and similar content into standalone files and use go:embed directive to access it?

Copy link
Member Author

Choose a reason for hiding this comment

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

All templates in Kubebuilder are currently done this way. I might not have fully understood the reasoning, but if we decide to change the approach, it would probably make sense to update all places consistently. That said, we’re always open to ideas—feel free to open a PR to propose the change and demonstrate what it would look like.

Comment on lines 190 to 192
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
# kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can get incorporate this waiting into the previous helm install step by doing something like:

helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set crds.enabled=true --wait --timeout 300s
#

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems a good idea. 🚀

@camilamacedo86
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-33-0

…`) that dynamically generates Helm charts based on the actual kustomize output from `make build-installer`, replacing the previous hardcoded template approach in `helm/v1-alpha`.

The existing `helm/v1-alpha` plugin used static templates that didn't reflect user customizations (environment variables, labels, annotations, security contexts, etc.) made in their kustomize configuration. This led to inconsistencies between `kubectl apply -f dist/install.yaml` and `helm install`.

- Deprecated Helm v1-alpha in favour of v2
- Add docs and tests for Helm v2
- Update all samples
- Address all feedbacks raised so far

Assisted-by: OpenAI
@camilamacedo86
Copy link
Member Author

We have enough reviews/lgtm so far
Also, to allow contributions on top of those changes we need get this one merged
So, I am letting it move forward.
We have up to the next release to enhance or change what might be required.

@manfredlift
Copy link

The args for controller-manager container needs to be templated and available in values.yaml (with defaults or empty [ ] )
Otherwise it won't be possible to dynamically include args.

@camilamacedo86, just tried this out. It seems like also the values for image and resources in manager.yaml are hardcoded (and come from dist/install.yaml) and the ones in values.yaml are not used?

@camilamacedo86
Copy link
Member Author

@manfredlift and @abhijith-darshan

Both scenarios reported are tracked for helm/v2

@atanasenko
Copy link

@camilamacedo86 This is so much better than v1.
We do have an additional Deployment added to the stack that is basically a web ui accompanying the the operator. However, the helm v2 plugin seems to only support a single Deployment and only the last one encountered, silently ignoring all the rest.

@camilamacedo86
Copy link
Member Author

Hi @atanasenko

Thank you for the report. Please create an issue with the scenario so that we can try to address it.
Could you please add the code and how we reproduce it?

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants