kustomize: [kustomize 2.1.0] cannot read data from configMap
I hit the problem with kustomize 2.1.0, but that works fine with kustomize 2.0.3, I’m not sure is that broken by kustomize 2.1.0 or design behavior changed?
Base kustomization.yaml
[root@jinchi1 local]# cat ../base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
...
vars:
...
- fieldref:
fieldPath: data.batchSize
name: batchSize
objref:
apiVersion: v1
kind: ConfigMap
name: mnist-map-training
...
Local kustomization.yaml
[root@jinchi1 local]# cat kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../base
.....
configMapGenerator:
- literals:
- name=mnist-train-local
- batchSize=100
....
name: mnist-map-training
[root@jinchi1 local]# kustomize build . Error: var ‘{batchSize ~G_~V_ConfigMap {data.batchSize}}’ cannot be mapped to a field in the set of known resources [root@jinchi1 local]# kustomize version Version: {KustomizeVersion:2.1.0 GitCommit:af67c893d87c5fb8200f8a3edac7fdafd61ec0bd BuildDate:2019-06-18T22:01:59Z GoOs:linux GoArch:amd64}
But that works fine with kustomize v0.2.3. Could someone to take a look? thanks a lot!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (4 by maintainers)
@jbrette @monopole Could you please help to double confirm and fix this? thanks a lot! /P1
This issue still persists in kustomize v4.2.0. If the generator and vars are defined in the same file it works, but if the var is on one file(say base, for example) and the generator is on another file(production) it won’t work.
Did more deep tests, if both of
varsandconfigMapGeneratorare in same kustomization.yaml, that’s OK. In other words, both thevarsandconfigMapGeneratorneed to inbase/kustomization.yamlor both inlocal/kustomization.yaml. But failed ifvarsdefined inbase, andconfigMapGeneratordefined inlocal/kustomization.yaml.Personally we should fix that, for reasons:
varspath will be same, user would like to set in the base, but the value is not same, user would like to set in local.