PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] How to use enviroment variables in Envoy

 August 19, 2022     environment-variables, envoyproxy, yaml     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing