<p>I have a 3rd party docker container which takes arguments of the form:</p>
<pre><code>docker run foo --arg1 val1 --arg2 val2
</code></pre>
<p>and I have run it as a pod in kubernetes as follows:</p>
<pre><code>spec:
  containers:
  - name: foo
    image: foo
    args:
    -  --arg1
    - val1
    - --arg2
    - val2
</code></pre>
<p>This is good but I now need to have the two argument values dynamic. For example, val1 is the pod's name/id, and val2 is the <em>zone</em> (aws availability zone) of the node that the Pod is running on.</p>
<p>The only solution so I could think of is, to extend the container creating another image that runs a wrapper script, which queries for these two values and then pass them to the command line.</p>
<p>I am wondering if there's a more elegant solution than that. Let's say we can <em>obtain</em> these dynamic values in an <em>initContainer</em>. Now the question is how do we pass them on the command line of the main container.</p>
<p>PS: It looks like we can get the pod's name using Downward API. However, the Downward API does not expose node's label, for which there is an open <a href="https://github.com/kubernetes/kubernetes/pull/25957" rel="nofollow noreferrer">issue</a>. So, for this question, let's think our parameters are arbitrary and are obtained dynamically.</p>

vrtx54234
<p>You will be able to pass arguments as mentioned below.</p>
<p>HOSTNAME env will provide the detail for POD_NAME</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/</a></li>
</ul>
<p>AWS Region specific details.</p>
<ul>
<li><a href="https://stackoverflow.com/questions/36690446/inject-node-labels-into-kubernetes-pod">Inject node labels into Kubernetes pod</a></li>
</ul>
<p><strong>OR</strong></p>
<p>Run kubectl command on intialization and use node label with --show-labels to get region specific details based on assigned pod node.</p>
