Skip to content

Add possibility to modify find arguments #831

Open
@kamazee

Description

@kamazee

Is your feature request related to a problem? Please describe

When a configmap is mounted as a directory rather that every individual file is mounted, Kubernetes creates files with its own internal names that contain timestamp and then creates symlinks at the desired destination to the actual location. For example, when a configmap is mounted into /etc/nginx/templates, it looks somewhat like this:

drwxrwxrwx    3 root     root        4.0K Mar  3 19:44 .
drwxr-xr-x    1 app      app         4.0K Mar  3 19:34 ..
drwxr-xr-x    2 root     root        4.0K Mar  3 19:44 ..2023_08_18_16_14_47.392410265
lrwxrwxrwx    1 root     root          31 Mar  3 19:44 ..data -> ..2023_08_18_16_14_47.392410265
lrwxrwxrwx    1 root     root          18 Mar  3 19:40 default.conf.template -> ..data/default.conf.template

It results into default.conf being rendered multiple times:

20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/..2023_08_18_16_14_47.392410265/default.conf.template to /etc/nginx/conf.d/..2023_08_18_16_14_47.392410265/default.conf
20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/..data/default.conf.template to /etc/nginx/conf.d/..data/default.conf
20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf

Apparently, nginx won't start because of duplication in config.

Describe the solution you'd like

While this is not really the nginx's issue and this is how configmaps work, it would be nice to still have possibility to mount configmap as a directory and have only the expected entries rendered into resulting config directory.
For example, ! -name '..*' (or similar) added to find would do in my case.

So, it can be either a simple option designated for working around configmaps structure which would optionally add a predefined search terms to find or just an ability to pass arbitrary terms via environment variables (in the same way as template extension is redefined, for example).

Describe alternatives you've considered

As a workaround, the whole 20-envsubst-on-templates.sh can be replaced and do whatever one wants it to do but I assume that the issue with configmap structure affects every single person who mounts the whole template directory and I'd appreciate the out-of-the box solution for this

Additional context

I don't have anything to add but ready to answer questions if there are any or contribute the solution we'd agree upon in a discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions