<p>I am trying to run a kubectl exec command on a pod, but it fails  saying <em>'No such file or directory'</em></p>
<p>I can run the command if I login to the terminal of the pod through bash
Also this problem is only for a few commands.
I found that there is a PATH variable difference</p>
<ol>
<li><p>When i do kubectl exec $POD -- printenv  , then
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</p>
</li>
<li><p>When i run -- printenv from the terminal of POD  , then
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/abc/scripts:/opt/abc/bin:/opt/admin/bin:/opt/abc/bin:/root/bin</p>
</li>
</ol>
<p>I am guessing this is causing the commands to fails when run through kubectl exec.</p>
<p>Any ideas to overcome this are welcome; can we pass the env variable of PATH in someway to the POD which using kubectl exec ?</p>

user19240299
<p>You can try executing <code>bash -c &quot;&lt;command&gt;&quot;</code></p>
<pre><code>$ kubectl exec &lt;pod&gt; -- bash -c &quot;&lt;cmd&gt;&quot; 
</code></pre>
<p>It is likely PATH is being modified by some shell initialization files</p>
