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).
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}.
Most helpful comment
I'm running the latest stable kubectl version 1.15.3, and for comparison, standalone
kustomizeversion 3.1.0. Neither of them has a--from-files='...'option.Can someone clarify whether this feature was removed (or has never worked)?