kustomize - Using the same configuration file for different ConfigMaps

89 Views Asked by At

I have a kustomize project with some overlays that use different bases with different configMaps. Something like this:

ConfigMap.env
kustomize
├─ base
│  └─ kustomization.yaml
│      ...
│      configMapGenerator:
│        - name: config1
│          envs:
│            - ../ConfigMap.env
│        - name: config1
│          behavior: merge
│          literals:
│            - ENV_VAR1=SOME_VALUE
│      ...
├─ base2
│  └─ kustomization.yaml
│      ... 
│      configMapGenerator:
│        - name: config2
│          envs:
│            - ../ConfigMap.env
│        - name: config2
│          behavior: merge
│          literals:
│            - ENV_VAR1=SOME_OTHER_VALUE
│      ...
├─ base3
│  └─ kustomization.yaml
│      ... 
│      configMapGenerator:
│        - name: config3
│          envs:
│            - ../ConfigMap.env
│        - name: config3
│          behavior: merge
│          literals:
│            - ENV_VAR1=YET_SOME_OTHER_VALUE
│      ...
│
...
├─ overlays
   ├─ overlay1 # with some deployments using config1 and config2
   │   ...
   ├─ overlay2 # with some deployments using config1, config2 and config3
   │   ...
   ├─ overlay3 # with some deployments using config2 and config3
   │   ...
   └─ overlay4 # with some deployments using confgi1

Problem is that I updated kustomize version and it's not working anymore and now I'm getting the following error when trying to run kustomize edit

file 'ConfigMap.env' is not in or below 'kustomize/folder'

I already tried using --load-restrictor LoadRestrictionsNone but it doesn't work with kustomize edit.

Do you know what I can do to make this work? this restriction that kustomize set in place doesn't make any sense to me.

0

There are 0 best solutions below