我有一个nginx ConfigMap yaml文件,然后被挂载为nginx.conf。此配置映射包含多行字符串形式的配置,其开头类似于:
data:
nginx.conf: |
worker_processes auto;
pid /tmp/nginx.pid;
:在这个多行字符串中,我想从values.yaml中注入一个值,例如:
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;
:但是使用上面的语法,我得到了一个意外的EOF错误。有什么办法/变通办法来完成这件事吗?
发布于 2021-06-23 22:32:05
好吧,我建议你避免这样做。相反,您可以创建一个文件夹,如configuration,与您的template文件夹同级,并在其中创建一个名为nginx.conf的文件,其中包含您的整个字符串内容,当然,这些内容可以具有所需的占位符。然后,在configMap定义中,您可以这样调用您的文件
data:
{{ (.Files.Glob "configuration/nginx.conf").AsConfig | indent 2 }}这将创建您的configmap
https://stackoverflow.com/questions/68088015
复制相似问题