0

I'm having an nginx ConfigMap yaml file which is then mounted as nginx.conf. This config map contains the config in a multiline string starting like the following:

data:
  nginx.conf: |
    worker_processes  auto;
    pid /tmp/nginx.pid;
    :

and in this multiline string I'd like to inject a value from the values.yaml like for example:

data:
  nginx.conf: |
    worker_processes  auto;
    pid /tmp/nginx.pid;

:
:
        log_format combined '$remote_addr - $remote_user [$time_local] '
                           '"$request" $status $body_bytes_sent '
                           '"$http_referer" "$http_user_agent"';

        access_log /var/log/nginx/access.log {{ .Values.nginx.log.format | default "combined" | quote }};
        error_log /var/log/nginx/error.log;
:

but using the syntax above I'm getting an unexpected EOF error. Any way/work-around to get this done?

hhue13
  • 11
  • 3

1 Answers1

-1

Well, I would suggest you to avoid doing this. Instead, you can create a folder such as configuration, sibling to your template folder and create a file named nginx.conf in it with your entire string content which of course can have required placeholders. Then, in configMap definition, you can call your file like this

data:
{{ (.Files.Glob "configuration/nginx.conf").AsConfig | indent 2 }}

This would create your configmap

Nish
  • 922
  • 13
  • 31