Kustomize: configMapGenerator should allow directories as input, like kubectl

Created on 21 Jul 2018  ยท  9Comments  ยท  Source: kubernetes-sigs/kustomize

Given this dir tree:

configs/
โ”œโ”€โ”€ config.d/
โ”‚   โ”œโ”€โ”€ 10-input.conf
โ”‚   โ”œโ”€โ”€ 50-filter.conf
โ”‚   โ””โ”€โ”€ 90-output.conf
โ”œโ”€โ”€ ssl.conf
โ””โ”€โ”€ app.conf

You can do the following with kubectl:

kubectl create configmap my-config --from-file=configs

This creates a configmap containing all first level files from the configs/ folder (i.e. ssl.conf and app.conf). This is quite useful when you have .d folders like the one above where you can just drop in new config files and be done with it.

I would love to be able to do that with configMapGenerator as well. Right now there is only the option to include individual files (unless I missed something in the code).

Most helpful comment

I'm running the latest stable kubectl version 1.15.3, and for comparison, standalone kustomize version 3.1.0. Neither of them has a --from-files='...' option.

Can someone clarify whether this feature was removed (or has never worked)?

All 9 comments

Similar to resources from a directory

resources:
- res/*.yaml

we can add glob support in configMapGenerator, then this can be declared as

configMapGenerator:
- name: some-name
  files:
   - configs/*.conf
   - configs/config.d/*.conf

Oh yeah! That's actually a lot more powerful, good idea :-)

To move towards explicit dependency declaration, we're moving away from allowing globs in the kustomization file, and towards adding kustomization editting commands that support globbing - see
#217, #218

The existing command kustomize edit add configmap could be modified to act as described :)

To add files under a directory to a configmap, use following command

kustomize edit add configmap some-name --from-files=somedir/*.conf

Sweet! Can't wait to test it! Awesome job on the implementation speed :-)

Is this still working?
I'm running 2.0.1 (shiny and new) and am trying to use globbing but it throws:

Error: NewResMapFromConfigMapArgs: NewResMapFromConfigMapArgs: file sources: [configs/*.yaml]: evalsymlink failure on '/<somepath>/configs/*.yaml' : lstat /<somepath>/configs/*.yaml: no such file or directory

But the files are most definitely there.
Was the support for globbing in configMapGenerator dropped?

EDIT: Just read this, guess it was really dropped.

@mamoit This is working. You have to quote the path with the asterisk:

kustomize edit add configmap some-name --from-files='somedir/*.conf'

Somewhat related: #914

I'm running the latest stable kubectl version 1.15.3, and for comparison, standalone kustomize version 3.1.0. Neither of them has a --from-files='...' option.

Can someone clarify whether this feature was removed (or has never worked)?

This worked for me (from-file singular, not plural as suggested):

kustomize edit add configmap my-configmap --from-file='config/files/*.conf'

On Kustomize version {Version:3.8.1 GitCommit:0b359d0ef0272e6545eda0e99aacd63aef99c4d0 BuildDate:2020-07-16T05:15:32+01:00 GoOs:darwin GoArch:amd64}.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bcbrockway picture bcbrockway  ยท  5Comments

Liujingfang1 picture Liujingfang1  ยท  4Comments

wuestkamp picture wuestkamp  ยท  3Comments

monopole picture monopole  ยท  3Comments

nabadger picture nabadger  ยท  4Comments