Include generic Services in Helm v2-alpha chart generation
Fixes #5248
The Helm v2-alpha plugin currently only includes Service resources whose names contain the substrings "webhook" or "metrics". All other Service objects found under config/services/ are silently dropped during chart generation. This results in missing Service definitions in the final Helm chart, even though these Services are included in the install.yaml produced by kustomize.
Root Cause
Within resource_organizer.go, Services are only classified under:
- "webhook" (via isWebhookService)
- "metrics" (via isMetricsService)
Any Service that does not match these filters is never added to any group, and therefore excluded from the final Helm chart output.
Summary of Changes
This PR introduces support for "generic" Services—Service resources that are
neither webhook nor metrics related—by grouping them under a new services
category. This ensures all user-defined Services are included in the Helm
chart.
A new function was added:
// isGenericService determines if a service is neither webhook nor metrics.
func (o *ResourceOrganizer) isGenericService(service *unstructured.Unstructured) bool {
return !o.isWebhookService(service) && !o.isMetricsService(service)
}
A new collector was added:
// collectGenericServices gathers generic Service resources.
func (o *ResourceOrganizer) collectGenericServices() []*unstructured.Unstructured {
var generic []*unstructured.Unstructured
for _, service := range o.resources.Services {
if o.isGenericService(service) {
generic = append(generic, service)
}
}
return generic
}
And the main organizer now includes these Services:
genericServices := o.collectGenericServices()
if len(genericServices) > 0 {
groups["services"] = genericServices
}
✅ Tests Added
This PR also includes a new unit test (generic_services_test.go) that verifies:
- A Service without "webhook" or "metrics" in its name
- is correctly detected as a generic Service
- and is added to the "services" group during chart organization
The test follows the existing Ginkgo/Gomega test structure used by the project.
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: UJESH2K / name: UJESH KUMAR YADAV (c35be1804bce7591335d15ca5d731dc4e49e406e)
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: UJESH2K Once this PR has been reviewed and has the lgtm label, please assign kavinjsir for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Welcome @UJESH2K!
It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
Hi @UJESH2K. Thanks for your PR.
I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
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.
Partial support is not ideal here. I’m happy to refactor this into a generic solution that ports any non-scaffolded resource from install.yaml, instead of special-casing Services. If that direction works for you, I’ll update the PR accordingly.
I wanted to clarify the overall approach in this PR.
Previously, not all resources from the generated install.yaml were making it through the helm/v2-alpha pipeline, which meant some user-defined resources were never even considered for classification and were silently dropped.
With this change, all resources produced by kustomize are now parsed and tracked first. From there, resources that are recognized by the default helm/v2-alpha scaffolds are classified and written as usual. Any remaining resources that are not classified are preserved under templates/extras, and a warning is emitted to make this behavior visible to users.
The key change here is ensuring that nothing is lost during parsing, so classification happens on a complete set of resources rather than a partial one.
/ok-to-test
@UJESH2K
Thank you for looking into this 🙂 I’ve updated the PR title — I hope that’s okay.
Could you please make sure we have a mock scenario that properly validates these changes? For example, we should include extra ConfigMaps, Services, etc., and confirm that all of them end up in the extra directory.
Also, can we make sure we only change what is required to achieve the goal? For example, could you please revert the removal of comments?
Lastly, could you ensure the changes pass all CI checks? I noticed the lint check is currently failing. Please also make sure the PR description matches the latest changes.
Thank you!