Skip to content
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

configMapGenerator unable to replace ConfigMap from a Helm chart #4799

Closed
cjyar opened this issue Sep 16, 2022 · 6 comments
Closed

configMapGenerator unable to replace ConfigMap from a Helm chart #4799

cjyar opened this issue Sep 16, 2022 · 6 comments
Labels
kind/support Categorizes issue or PR as a support question. triage/resolved Indicates an issue has been resolved or doesn't need to be resolved.

Comments

@cjyar
Copy link

cjyar commented Sep 16, 2022

Describe the bug

Kustomize is unable to replace the contents of a ConfigMap if the ConfigMap comes from the Helm generator.

Files that can reproduce the issue

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmCharts:
- name: vault
  namespace: vault
  releaseName: vault
  repo: https://helm.releases.hashicorp.com
  version: 0.22.0

configMapGenerator:
- behavior: replace
  literals:
  - thing=stuff
  name: vault-config
  namespace: vault
  options:
    disableNameSuffixHash: true

Expected output

It should generate manifests

Actual output

Error: merging from generator &{0xc00028a5b0 <nil>}: id resid.ResId{Gvk:resid.Gvk{Group:"", Version:"v1", Kind:"ConfigMap", isClusterScoped:false}, Name:"vault-config", Namespace:"vault"} does not exist; cannot merge or replace

If I remove behavior: replace then I get this instead:

Error: merging from generator &{0xc0000dc480 <nil>}: id resid.ResId{Gvk:resid.Gvk{Group:"", Version:"v1", Kind:"ConfigMap", isClusterScoped:false}, Name:"vault-config", Namespace:"vault"} exists; behavior must be merge or replace

Kustomize version

{Version:kustomize/v4.5.7 GitCommit:56d82a8378dfc8dc3b3b1085e5a6e67b82966bd7 BuildDate:2022-08-02T16:28:01Z GoOs:darwin GoArch:amd64}

Platform

macOS

@cjyar cjyar added the kind/bug Categorizes issue or PR as related to a bug. label Sep 16, 2022
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 16, 2022
@k8s-ci-robot
Copy link
Contributor

@cjyar: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@annasong20
Copy link
Contributor

Hi @cjyar, I see the same error running kustomize v4.5.7 on macOS using the given kustomization.yaml.

I don't believe this is a bug. Kustomize runs its built-in kustomization fields in a certain order; the helmCharts generator is ahead of configMapGenerator in that order. Therefore, when kustomize runs configMapGenerator, it has yet to generate the helm chart specified and hence, the error.

An easy workaround is to move the configMapGenerator, as a plugin, under generators because kustomize runs plugins after built-in fields. You'd run kustomize build --enable-helm on the setup below:
kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmCharts:
- name: vault
  namespace: vault
  releaseName: vault
  repo: https://helm.releases.hashicorp.com
  version: 0.22.0

generators:
- configmap-generator.yaml

configmap-generator.yaml

apiVersion: builtin
kind: ConfigMapGenerator
behavior: replace
metadata:
  name: vault-config
  namespace: vault
literals:
  - thing=stuff
options:
  disableNameSuffixHash: true

Hope this helps.

@KnVerey
Copy link
Contributor

KnVerey commented Sep 28, 2022

/kind support
/triage resolved
/close

Feel free to re-open with more detail if the proposed solution doesn't work for you.

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. triage/resolved Indicates an issue has been resolved or doesn't need to be resolved. labels Sep 28, 2022
@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

/kind support
/triage resolved
/close

Feel free to re-open with more detail if the proposed solution doesn't work for you.

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/test-infra repository.

@KnVerey KnVerey removed kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 28, 2022
@preetsindhal
Copy link

Is there any way i can achieve the same on fluxcd using helmrelease, I tired the generators: approach it didn't work :(

Thanks

tosmi added a commit to tosmi-gitops/openshift-gitops that referenced this issue Dec 4, 2023
@celonis-eg
Copy link

Just for anyone reading--the recommendation above doesn't seem to work with either the replace or the merge behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. triage/resolved Indicates an issue has been resolved or doesn't need to be resolved.
Projects
None yet
Development

No branches or pull requests

6 participants