如何在 Envoy 中使用环境变量
如何指定主机和端口数据而不将其显式写入 yaml 文件中?我想使用环境变量,但到目前为止我所有的尝试都会导致 json 解析器错误。
How can I specify host and port data without writing it explicitly in the yaml file? I'd like to use environment variables, but so far all my attempts result in a json parser error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1
您需要使用EnvSubst的选项,该工具可以帮助您将变量放入Envoy.yaml。您可以在路径TMPL/Envoy.yaml.tmpl的路径中这样做,
我们保存我们的临时配置,在其中使用$ arg_1和$ arg_2的处方。然后,我们将这些变量从.env中取出。因此,我们可以运行的最终配置将在/etc/envoy.yaml中。
如果您想了解有关EnvSubst的更多信息,我建议您阅读以下文章:
2
使用jinja2 + python将您的template.j2文件渲染到yaml。您可以在Google中找到更多有用的信息或阅读本文:
1 Option
You need to use envsubst, a tool that helps you put variables into envoy.yaml. You can do it this way
In the path tmpl/envoy.yaml.tmpl we save our temporary config where we prescribed where $ARG_1 and $ARG_2 will be used. Then we take these variables out of .env and rewrite $ARG_1 and $ARG_2 in the new config to their values. So our final config that we can run will be in /etc/envoy.yaml.
If you would like to learn more about envsubst, I recommend reading the following articles:
2 Option
Also you can use jinja2 + python to render your template.j2 files to yaml. You can find more useful information in Google or read this article:
Generate yaml file with python and jinja2.