<p>I'm trying to run a python script from kubernetes with input args (using import argsparse on python), the python script running fine without any input args on kubernetes, also the following command <code>python python_script.py -e $(date -d '2020/08/23') -d 7 -m</code> runs with no issues on the docker image.</p>
<p>I'm trying to build my values.yaml file so kubernetes could run it as well, with no success until now.</p>
<p>My values.yaml file (only relevant part to the script):</p>
<pre><code>- name: python-script
  command: [&quot;python&quot;]
  args:
    - &quot;python_script.py&quot;
    - &quot;-e $(date -d '2020/08/23')&quot;
    - &quot;-d 7&quot;
    - &quot;-m&quot;
  resources:
    limits:
      cpu: 50m
      memory: 512Mi
    requests:
      cpu: 50m
      memory: 512Mi
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  restartPolicy: Never
</code></pre>
<p><strong>Output when running on kubernetes</strong> : <code>python_script.py: error argument -e/--end_date: Not a valid date: ' $(date -d &quot;2020/08/23&quot;)'.</code></p>
<p>It's like the kubernetes doesn't even parse the bash command <code>$(date -d &quot;2020/08/23&quot;)</code> into a valid date for some reason, while the docker image there's no issues with it.</p>
<p>I tried to add another command of <code>[&quot;bash&quot;]</code> after the python file and add the args there but still getting error.</p>
<p>Any ideas? Any help will be really appreciated!</p>
<p>Thanks.</p>

JaVaPG
<p>When you run with command <code>python</code>, then <code>shell</code> is not invoked.</p>
<p>So try:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: python-script
  command: [&quot;/bin/sh&quot;]
  args:
    - -c
    - &gt;-
        python python_script.py
        -e $(date -d '2020/08/23')
        -d 7
        -m
  resources:
    limits:
      cpu: 50m
      memory: 512Mi
    requests:
      cpu: 50m
      memory: 512Mi
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  restartPolicy: Never
</code></pre>
