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 merge ignores previous namePrefix applications #1442

Closed
jcpetruzza opened this issue Aug 12, 2019 · 0 comments · Fixed by #1520
Closed

configMapGenerator merge ignores previous namePrefix applications #1442

jcpetruzza opened this issue Aug 12, 2019 · 0 comments · Fixed by #1520
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@jcpetruzza
Copy link
Contributor

From kustomization c, I want to extend a configMap imported from resource b, where a name-prefix was added to a configMap originally defined in a. I expect to use b's name to denote the name of the configMap, but have to use a's instead. Full example:

$ cat a/kustomization.yaml
configMapGenerator:
- name: cm
  literals:
  - FOO=BAR

$ cat b/kustomization.yaml
resources:
- ../a
namePrefix: renamed-

$ cat c/kustomization.yaml
resources:
- ../b
configMapGenerator:
- name: cm   # <-- should be renamed-cm!
  behavior: merge
  literals:
  - HELLO=WORLD

$ kustomize build c
apiVersion: v1
data:
  FOO: BAR
  HELLO: WORLD
kind: ConfigMap
metadata:
  annotations: {}
  labels: {}
  name: renamed-cm-27kg5g5b5c

Notice that if I use renamed-cm in c/kustomization.yaml, I get this error:

Error: merging from generator &{0xc0000eeb40 0xc0004d5a60 { } {map[] map[] false} {{ renamed-cm merge {[HELLO=WORLD] [] [] }}}}: id resid.ResId{Gvk:gvk.Gvk{Group:"", Version:"v1", Kind:"ConfigMap"}, Name:"renamed-cm", Namespace:""} does not exist; cannot merge or replace

This is not only confusing, it also means that one cannot define a base configMap, produce two different versions of it with namePrefix, and then extend only one (actually, one can't even extend both at the same time, since kustomize will fail with found multiple objects ... that could accept merge of ...).

$ kustomize version                                                                                                                                 
Version: {KustomizeVersion:3.1.0 GitCommit:95f3303493fdea243ae83b767978092396169baf BuildDate:unknown GoOs:linux GoArch:amd64}
@Liujingfang1 Liujingfang1 added the kind/bug Categorizes issue or PR as related to a bug. label Aug 26, 2019
jcpetruzza added a commit to jcpetruzza/kustomize that referenced this issue Sep 10, 2019
When merging resources such as the output of a `configMapGenerator`,
we need to consider the `CurrentId`, otherwise, we cannot extend
a common base definition twice by adding different prefixes, and
then further kustomize them.

This fixes kubernetes-sigs#1442.
jcpetruzza added a commit to jcpetruzza/kustomize that referenced this issue Sep 10, 2019
When merging resources such as the output of a `configMapGenerator`,
we need to consider the `CurrentId`, otherwise, we cannot extend
a common base definition twice by adding different prefixes, and
then further kustomize them.

This fixes kubernetes-sigs#1442.
jcpetruzza added a commit to jcpetruzza/kustomize that referenced this issue Sep 10, 2019
When merging resources such as the output of a `configMapGenerator`,
we need to consider the `CurrentId`, otherwise, we cannot extend
a common base definition twice by adding different prefixes, and
then further kustomize them.

See kubernetes-sigs#1442.
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants