<p>I want to run a mongodb command in Kubernetes deployment.
In my yaml file, I want to run the following:</p>

<pre><code>command: ["mongo --port ${MONGODBCACHE_PORT} --host ${MONGODBCACHE_BIND_IP}  \
                  --eval "rs.initiate('{ _id: \"test\", members: [ { _id: 0, host: \"${MONGODBCACHE_BIND_IP}:${MONGODBCACHE_BIND_IP}\" },]}')"  &amp;&amp; \
                  ./mycommand "]
</code></pre>

<p>I checked that the environment variables are present correctly. How do I escape the characters when running this command?</p>

kosta
<p>Use only <code>mongo</code> in command and the others in args field which is an array. Like,</p>

<pre><code>command: ["/bin/bash", "-c"]
args:
- mongo
- --port
- ${MONGODBCACHE_PORT}
- --host
- ${MONGODBCACHE_BIND_IP}
- --eval
- rs.initiate('{ _id: "test", members: [ { _id: 0, host: "${MONGODBCACHE_BIND_IP}:${MONGODBCACHE_BIND_IP}" } ] }')  &amp;&amp; ./mycommand
</code></pre>

<p>Hope this will help.</p>
