<p>I plan to upgrade my project to HELM.</p>
<p>I have many environment variables that I have defined in deployment.yaml.</p>
<p>Best practice is it best to define the environment variables in the values.yaml file or the templates / deployment.yaml drop?</p>
<p>Can you help if there is a sample application you use?</p>

public_html
<p>Disclaimer: My answers are based on Helm 3. So let's get to it:</p>
<ul>
<li>#1: No, in your values.yaml you define the static/default values. It's not the best approach to let static values in your template files (like deployment.yaml). To override the values of values.yaml The best practice is to use <a href="https://helm.sh/docs/helm/helm_install/" rel="nofollow noreferrer">--set KEY=VALUE</a> file. In this case, is totally possible to get the environment variable.</li>
<li>#2: Can you give an example? Yes, sure.</li>
</ul>
<p>For example, I want to install Elasticsearch on my cluster using helm so I use the command:</p>
<pre><code>helm install elastic/elasticsearch --version 7.8.0
</code></pre>
<p>But I do not want to use the default values of the chart. So I went to <a href="https://hub.helm.sh/charts/elastic/elasticsearch" rel="nofollow noreferrer">https://hub.helm.sh/charts/elastic/elasticsearch</a> and <a href="https://github.com/elastic/helm-charts/blob/7.8/elasticsearch/values.yaml" rel="nofollow noreferrer">https://github.com/elastic/helm-charts/blob/7.8/elasticsearch/values.yaml</a>, saw what's possible to change, then I create the command:</p>
<pre><code>helm install elastic/elasticsearch --set minimumMasterNodes=1 --set protocol=https  --version 7.8.0
</code></pre>
<p>But in my CD tool, the minimum master nodes are different values and since this is an environment variable I changed my command line to this:</p>
<pre><code>helm install elastic/elasticsearch --set minimumMasterNodes=$MIN_MASTER_NODES --set protocol=https  --version 7.8.0
</code></pre>
<p>So, as a result, the command above will run with no problem in your CD tool once the MIN_MASTER_NODES environment variable is provided correctly.</p>
