<p>I echoed all my env variables and they're there, but when I try to read them from command section, <strong>they are empty</strong>.</p>

<pre><code>          command:
            - /bin/sh
            - -c
            - &gt;
              if [ ! -f /data/db/admin-user.lock ]; then
                echo "KUBERNETES LOG $HOSTNAME - no Admin-user.lock file found yet" &gt;&gt; /data/db/configlog.txt;
                env &gt;&gt; /data/db/configlog.txt;
                while (! mongo --eval "db.adminCommand('ping')"); do sleep 10; echo "KUBERNETES LOG $HOSTNAME - waiting another 10 seconds for mongo to start" &gt;&gt; /data/db/configlog.txt; done;
                touch /data/db/admin-user.lock
                echo "KUBERNETES LOG $HOSTNAME - try create user with user=$MONGODB_CREATE_USER and pass=$MONGODB_CREATE_PASSWORD..." &gt;&gt; /data/db/configlog.txt;
</code></pre>

Wilson López
<p>You can use this for your command or args field.</p>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments" rel="nofollow noreferrer">Use environment variables to define arguments</a></p>

<blockquote>
  <p>Note: The environment variable appears in parentheses, "$(VAR)". This is required for the variable to be expanded in the command or args field.</p>
</blockquote>

<pre><code>env:
- name: ARGUMENT
  value: {{ argument_1 }}
args: ["$(ARGUMENT)"]
</code></pre>

<p>Where {{ argument_1 }} is an environment variable.</p>
