Creating a configmap from a folder recursively

4,521 views
Skip to first unread message

ced

unread,
Apr 20, 2017, 9:57:59 AM4/20/17
to Kubernetes user discussion and Q&A
Hi all,

Is there a way to recursively go through a folder and from that make a configmap? Or is it on the roadmap?

Use case is to mount all files in a folder (and its subfolders) into a container as a volume.

'kubectl -f foldername/' supports the --recursive option.
But it seems
'kubectl create configmap' does not.

Is there another way to mount a bunch of folders with files in them into a container in such way that it is mounted on any container running the app on any node available.

Note I'm not using GCE or AWS or any public cloud provider..this is all internal, so no ability to use that type of volume mounting. Host mounts also won't work since then each host needs to have those folders there.. . I'd really like the functionality configmaps provide but then recursively.

Looking forward hearing your feedback, suggestions.

Thanks!

Ced

Rodrigo Campos

unread,
Apr 22, 2017, 3:41:43 PM4/22/17
to kubernet...@googlegroups.com
On Thu, Apr 20, 2017 at 10:57 AM, ced <cedric.v...@gmail.com> wrote:
>
> Hi all,
>
> Is there a way to recursively go through a folder and from that make a configmap? Or is it on the roadmap?

There isn't, and I don't know about the roadmap

>
> Use case is to mount all files in a folder (and its subfolders) into a container as a volume.

You can use the "--from-file" option and give it a directory, and it
will create a key for all the files in there. But won't go
recursively.

You can, however, make a configmap create subdirectories when it is
being mounted. You can specify the items array when in the configmap
volume: https://kubernetes.io/docs/api-reference/v1.6/#configmapvolumesource-v1-core
If you put something like "subdir/asd" to be the path, then the
directory "subdir" will be created when mounting the configmap.

So, you may be able to script this with current functionality :)
Reply all
Reply to author
Forward
0 new messages