E
E
EmachinesDIMA2022-03-03 00:58:57
Devops
EmachinesDIMA, 2022-03-03 00:58:57

How to pass config files with variables if not via ConfigMap which is read-only?

I catch an error starting nginx in k8s:

1) on the side of the image with the transfer of the nginx configuration to the image via the Dockerfile (as is: COPY *.conf /etc/nginx/conf.d/)

nginx -T

from pod - configuration file is missing, pod error:
envsubst: error while reading "standard input": Is a directory


2) exception of transferring the config to the Dockerfile and its description in the ConfigMap with the ${VIRTUAL_HOST} and ${BRANCH_NAME} variables.
nginx: [emerg] unknown "branch_name" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

there is no change of variables.

And because:
can't create /etc/nginx/conf.d/default.conf: Read-only file system

ConfigMap allows you to add read-only content .

How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2022-03-03
@EmachinesDIMA

In the official nginx images, it is enough to create them in /etc/nginx/templates/with the suffix .template.
The file with replacement variables is mounted as a /etc/nginx/templates/config.conf.template
Shell script, pulled by the entrypoint, copied with substitution and it turns out/etc/nginx/conf.d/config.conf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question