string - 如何使用 HELM-3 值多行字符串
问题描述
我有一个 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 错误。有什么办法/解决方法可以完成这项工作?
解决方案
好吧,我建议你避免这样做。相反,您可以创建一个文件夹,例如文件夹的configuration
同级template
文件夹,并创建一个在其中命名的文件nginx.conf
,其中包含您的整个字符串内容,当然可以有所需的占位符。然后,在 configMap 定义中,您可以像这样调用您的文件
data:
{{ (.Files.Glob "configuration/nginx.conf").AsConfig | indent 2 }}
这将创建您的配置图
推荐阅读
- mysql - MySQL - 如何使用变量名读取列值
- database - 将变更从开发环境迁移到生产环境
- python - 如何删除跳过测试的详细输出?
- python - python ndarray什么是返回值
- sql - 数据库 'yyy' 中请求的用户 'xxx' 的消息 'EXECUTE AS USER' 失败。步骤失败
- r - 如何使用模式中的信息在 R 中设置 odbc 连接
- python - 如何有效地调试在计算密集型程序结束时调用的部分代码?
- reactjs - Ionic IonRefresher 渲染 TypeError 不是函数
- c# - .NET MVC 查看表单输入值不接受用户输入
- c# - C# SQL Query 连续返回结果