Skip to content

(helm/v1-alpha) --force flag does not update values.yaml when kustomize manager spec has changed #4625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
abhijith-darshan opened this issue Mar 20, 2025 · 4 comments · May be fixed by #4782
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@abhijith-darshan
Copy link

abhijith-darshan commented Mar 20, 2025

What broke? What's expected?

When scaffolding the project with --plugins=helm.kubebuilder.io/v1-alpha any changes made to manager spec is not copied over to values.yaml when executing kubebuilder edit --plugins=helm/v1-alpha --force

Reproducing this issue

create a new project

$ kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4,helm.kubebuilder.io/v1-alpha

The scaffold generates a dist/chart

Next edit the spec of manager.yaml in config/manager/manager.yaml

for example increase the replica count to 2

apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  namespace: system
  labels:
    control-plane: controller-manager
    app.kubernetes.io/managed-by: kustomize
spec:
  selector:
    matchLabels:
      control-plane: controller-manager

  replicas: 2
....

run kubebuilder edit --plugins=helm/v1-alpha --force as recommended in the documentation update helm chart wit latest changes

$ kubebuilder edit --plugins=helm/v1-alpha --force
INFO Generating Helm Chart to distribute project  
INFO webhook manifests were not found at config/webhook/manifests.yaml 
INFO Successfully copied config/rbac/leader_election_role.yaml to dist/chart/templates/rbac/leader_election_role.yaml 
INFO Successfully copied config/rbac/leader_election_role_binding.yaml to dist/chart/templates/rbac/leader_election_role_binding.yaml 
INFO Successfully copied config/rbac/metrics_auth_role.yaml to dist/chart/templates/rbac/metrics_auth_role.yaml 
INFO Successfully copied config/rbac/metrics_auth_role_binding.yaml to dist/chart/templates/rbac/metrics_auth_role_binding.yaml 
INFO Successfully copied config/rbac/metrics_reader_role.yaml to dist/chart/templates/rbac/metrics_reader_role.yaml 
INFO Successfully copied config/rbac/role.yaml to dist/chart/templates/rbac/role.yaml 
INFO Successfully copied config/rbac/role_binding.yaml to dist/chart/templates/rbac/role_binding.yaml 
INFO Successfully copied config/rbac/service_account.yaml to dist/chart/templates/rbac/service_account.yaml 
INFO Successfully copied config/network-policy/allow-metrics-traffic.yaml to dist/chart/templates/network-policy/allow-metrics-traffic.yaml

check values.yaml in dist/chart/values.yaml the replica value is still 1

KubeBuilder (CLI) Version

4.5.1

PROJECT version

3

Plugin versions

layout:
- go.kubebuilder.io/v4
- helm.kubebuilder.io/v1-alpha

Other versions

go version 
go1.24.1 darwin/arm64
require (
        ....
	k8s.io/apimachinery v0.32.1
	k8s.io/client-go v0.32.1
	sigs.k8s.io/controller-runtime v0.20.2
)
kubectl version
Client Version: v1.32.1
Kustomize Version: v5.5.0
Server Version: v1.32.0

Extra Labels

No response

@abhijith-darshan abhijith-darshan added the kind/bug Categorizes issue or PR as related to a bug. label Mar 20, 2025
@abhijith-darshan abhijith-darshan changed the title (helm/v1-alpha) - force command does not update values.yaml when manager spec has changed (helm/v1-alpha) --force command does not update values.yaml when manager spec has changed Mar 20, 2025
@abhijith-darshan abhijith-darshan changed the title (helm/v1-alpha) --force command does not update values.yaml when manager spec has changed (helm/v1-alpha) --force flag does not update values.yaml when manager spec has changed Mar 20, 2025
@abhijith-darshan
Copy link
Author

It is also seems to generate static content for manager.yaml and values.yaml

Even when manager.yaml and values.yaml is deleted from the chart, executing kubebuilder edit --plugins=helm.kubebuilder.io/v1-alpha --force generates the default scaffolded values.yaml

also kubebuilder edit -h doesn't list --force flag as well

@abhijith-darshan abhijith-darshan changed the title (helm/v1-alpha) --force flag does not update values.yaml when manager spec has changed (helm/v1-alpha) --force flag does not update values.yaml when kustomize manager spec has changed Mar 20, 2025
@FishyFishPat
Copy link

I laso have the same problem. When I tried updating control-plane in the helm chart, after regeneration it gets reset to default I can can not find the source of where is this coming from.

@camilamacedo86
Copy link
Member

When scaffolding a project with --plugins=helm.kubebuilder.io/v1-alpha, any changes made to the manager deployment spec (via Kustomize) are not reflected in the Helm values.yaml after running:

kubebuilder edit --plugins=helm.kubebuilder.io/v1-alpha --force

This behavior occurs because, for the manager component, we use a fixed Helm template to ensure compatibility with Helm charts:

https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/manager/manager.go

This means:

  • Any manual updates in Kustomize (e.g., resource limits, env vars) are not carried over to the Helm chart.
  • The plugin does not currently sync values from the Kustomize overlays into Helm template structures.

💡 Possible Directions

  • One potential improvement could be to read from the Kustomize manager deployment and translate relevant fields into Helm-compatible values.yaml entries and templates.
  • Alternatively, we could document this limitation clearly to avoid confusion.

If anyone is interested in improving this behavior or has ideas on syncing Kustomize and Helm setups, feel free to open a PR or start a discussion!

@camilamacedo86 camilamacedo86 added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 31, 2025
@camilamacedo86 camilamacedo86 added this to the helm milestone Mar 31, 2025
@sarthaksarthak9
Copy link
Member

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
4 participants