helm/v2-alpha: support multiple deployments and sidecar containers in generated charts
Summary
The helm/v2-alpha chart converter assumes the default single-manager, single-container, single-ServiceAccount scaffold. It should also handle projects with multiple deployments and/or sidecar containers, and keep the ServiceAccount handling correct in those cases.
Background
pkg/plugins/optional/helm/v2alpha/scaffolds/internal/kustomize/helm_templater.go templates the manager Deployment by matching the first image: / resources: / args: block into .Values.manager.*, and templates every kind: ServiceAccount the same way:
- getDefaultContainerName is only used as a presence gate, not to scope edits to the manager container — so a sidecar's fields get rewritten to the manager's values or left with no knobs, depending on ordering.
- The Deployment path is guarded by isManagerDeployment, but the ServiceAccount path has no equivalent guard.
No live bug on today's default scaffold (one container, one SA, one deployment) — this is about making the converter robust as projects grow.
Use Cases
Given a kubebuilder project using the helm/v2-alpha plugin
When I generate the chart and run helm template
Scenario: manager pod with a sidecar container Given the manager Deployment has a sidecar container besides "manager" Then the manager container's image, resources, and args come from .Values.manager.* And the sidecar keeps its own image, resources, and args And the sidecar is exposed through its own values (or preserved unchanged)
Scenario: project with multiple deployments Given the project scaffolds more than one Deployment Then each Deployment is templated independently And manager-only substitutions do not leak onto the other Deployments
Scenario: multiple ServiceAccounts Given the project emits more than one ServiceAccount Then only the controller-manager account is gated by .Values.serviceAccount.enabled And the manager account's name, labels, and annotations do not land on the others
Scenario: default single-manager scaffold (regression) Given the default scaffold with one manager container and one ServiceAccount Then the rendered chart is unchanged from today
Source: kubernetes-sigs/kubebuilder