Skip to content

Conversation

@UJESH2K
Copy link

@UJESH2K UJESH2K commented Dec 7, 2025

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.

Copilot AI review requested due to automatic review settings December 7, 2025 12:25
@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Dec 7, 2025
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

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

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

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

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 7, 2025
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Dec 7, 2025
@UJESH2K UJESH2K changed the title Include generic Services in Helm v2-alpha chart generation (fixes #5248) Include generic Services in Helm v2-alpha chart generation Dec 7, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 7, 2025
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 addresses issue #5248 by adding support for generic Service resources in the Helm v2-alpha chart generation. Previously, only Services with "webhook" or "metrics" in their names were included in the generated Helm chart, causing other Service definitions to be silently dropped despite being present in the kustomize install.yaml.

Key Changes

  • Added isGenericService() method to identify Services that are neither webhook nor metrics related
  • Added collectGenericServices() method to gather these services into a separate group
  • Integrated generic services into OrganizeByFunction() under a new "services" category

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +159 to +169
// collectGenericServices gathers all other 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
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The new generic services functionality lacks test coverage. While the existing tests verify metrics services (lines 98-124 in chart_converter_test.go), there are no tests verifying that generic services (services without "webhook" or "metrics" in their names) are properly collected, organized into the "services" group, and written to the helm chart.

Consider adding a test case similar to the existing metrics service test that:

  1. Creates a service without "webhook" or "metrics" in its name
  2. Verifies it's written to dist/chart/templates/services directory
  3. Ensures the service is not placed in the webhook or metrics groups

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

I’ve added a new unit test (generic_services_test.go) that covers the generic Service behavior mentioned here.

The test verifies that a Service without "webhook" or "metrics" in its name is:

  • detected as a generic Service

  • included in the "services" group

  • not placed under "webhook" or "metrics"

This provides test coverage for the new logic introduced in this PR.
Let me know if additional integration-level chart output tests are needed.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 7, 2025
@UJESH2K UJESH2K requested a review from Copilot December 7, 2025 13:09
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,34 @@
package kustomize_test
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The test file is missing the Apache 2.0 copyright header that is present in all other test files in this directory. All test files in this package (suite_test.go, parser_test.go, chart_converter_test.go, helm_templater_test.go) include the standard copyright notice.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,34 @@
package kustomize_test
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The package declaration uses package kustomize_test which is inconsistent with other test files in this directory. All other test files (chart_converter_test.go, helm_templater_test.go, suite_test.go) use package kustomize. While both approaches are valid in Go, consistency within a package is important for maintainability.

Suggested change
package kustomize_test
package kustomize

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

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[helm/v2-alpha] Manual resources (such as Service) are filtered-out and not included in the final chart

2 participants