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)

Most upvoted comments

@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 vars and configMapGenerator are in same kustomization.yaml, that’s OK. In other words, both the vars and configMapGenerator need to in base/kustomization.yaml or both in local/kustomization.yaml. But failed if vars defined in base, and configMapGenerator defined in local/kustomization.yaml.

Personally we should fix that, for reasons:

  1. For most the cases, The vars path will be same, user would like to set in the base, but the value is not same, user would like to set in local.
  2. kustomize v2.0.3 supports that, we should have basic compatibility.