Issue
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.
Solution
1 Option
You need to use envsubst, a tool that helps you put variables into envoy.yaml. You can do it this way
cat /tmpl/envoy.yaml.tmpl | envsubst \$ARG_1,\$ARG_2 > /etc/envoy.yaml
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:
- https://skofgar.ch/dev/2020/08/how-to-quickly-replace-environment-variables-in-a-file/
- https://www.baeldung.com/linux/envsubst-command
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.
Answered By - Danila Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.