<p>I am writing a YAML file to use Kubernetes and I wondering how to pass variables to args field.</p>

<p>I need to do something like this :</p>

<pre><code>args:  ['--arg1=http://12.12.12.12:8080','--arg2=11.11.11.11']
</code></pre>

<p>But I don't want to hard code those values for <code>--arg1</code> and <code>--arg2</code>, instead it should be like,</p>

<pre><code>args:  ['--arg1='$HOST1,'--arg2='$HOST2]
</code></pre>

<p>How should I do this?</p>

<p>You have two options that are quite different and really depend on your use-case, but both are worth knowing:</p>

<p>1) <a href="https://github.com/helm/helm" rel="nofollow noreferrer">Helm</a> would allow you to create <em>templates</em> of Kubernetes definitions, that can use variables.<br>
Variables are supplied when you install the Helm chart, and before the resulting manifests are deployed to Kubernetes.<br>
You can change the variables later on, but what it does is regenerate the YAML and re-deploy "static" versions of the result (template+variables=YAML that's sent to Kubernetes)<br></p>

<p>2) <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">ConfigMaps</a> allow you to separate a configuration from the pod manifest, and share this configuration across several pods/deployments.<br>
You can later reference the ConfigMap from your pod/deployment manifests.</p>

<p>Hope this helps!</p>
