Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to modify find arguments #831

Open
kamazee opened this issue Aug 21, 2023 · 2 comments
Open

Add possibility to modify find arguments #831

kamazee opened this issue Aug 21, 2023 · 2 comments

Comments

@kamazee
Copy link

kamazee commented Aug 21, 2023

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.

@thresheek
Copy link
Collaborator

Hi @kamazee!

Thank you for your suggestion.

Can you tell a bit more about the environment this happens on? e.g. Kubernetes version, cloud provider, runtimes, etc?

@kamazee
Copy link
Author

kamazee commented Aug 22, 2023

Sure. It's self-hosted Kubernetes 1.22.8 at the moment where I'm deploying nginx to, but I think we're not really special as to how configmap works; here are few links that mention the same behavior:

Also, there is a PR on a similar matter but regarding entrypoint scripts: #731; in my case, I didn't override the whole docker-entrypoint.d and mounted just one script I needed instead, so I didn't hit this issue there, but generally, it exists there, too. So, if the options that are passed to find here (and below) and here (and below) were customizable, if would let me work around the way k8s mounts a configmap, and maybe help someone who wants their own layout there for any reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants