<p>I have this definition in my values.yaml which is supplied to job.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>command: [&quot;/bin/bash&quot;]
args: [&quot;-c&quot;, &quot;cd /opt/nonrtric/ric-common/ansible/; cat group_vars/all&quot;]
</code></pre>
<p>However, after the pod initializes, I get this error:
<code>/bin/bash: - : invalid option</code></p>
<p>If i try this syntax:</p>
<pre class="lang-yaml prettyprint-override"><code>command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
args: 
   - &gt;
   cd /opt/nonrtric/ric-common/ansible/ &amp;&amp;
   cat group_vars/all
</code></pre>
<p>I get this error: <code>Error: failed to start container &quot;ric-register-avro&quot;: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: &quot;/bin/sh -c&quot;: stat /bin/sh -c: no such file or directory: unknown</code></p>
<p>Both sh and bash are supplied in the image, which is CentOS 7</p>
<p>job.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: batch/v1
kind: Job
metadata:
  name: ric-register-avro
spec:
  backoffLimit: 0
  template:
    spec:
      containers:
        - image: &quot;{{ .Values.ric_register_avro_job.image }}&quot;
          name: &quot;{{ .Values.ric_register_avro_job.name }}&quot;
          command: {{ .Values.ric_register_avro_job.containers.command }}
          args: {{ .Values.ric_register_avro_job.containers.args }}
          volumeMounts:
          - name: all-file
            mountPath: &quot;/opt/nonrtric/ric-common/ansible/group_vars/&quot;
            readOnly: true
            subPath: all
      volumes:
        - name: all-file
          configMap:
            name: ric-register-avro--configmap
      restartPolicy: Never
</code></pre>
<p>values.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>global:
  name: ric-register-avro
  namespace: foo-bar

ric_register_avro_job:
  name: ric-register-avro
  all_file:
    rest_api_url: http://10.230.227.13/foo
    auth_username: foo
    auth_password: bar
  backoffLimit: 0
  completions: 1
  image: 10.0.0.1:5000/5gc/ric-app
  containers:
    name: ric-register-avro
    command: [&quot;/bin/bash&quot;]
    args: [&quot;-c cd /opt/nonrtric/ric-common/ansible/; cat group_vars/all&quot;]
  restartPolicy: Never
</code></pre>

molitann
<p>In your Helm chart, you directly specify <code>command:</code> and <code>args:</code> using template syntax</p>
<pre class="lang-yaml prettyprint-override"><code>command: {{ .Values.ric_register_avro_job.containers.command }}
args: {{ .Values.ric_register_avro_job.containers.args }}
</code></pre>
<p>However, the output of a <code>{{ ... }}</code> block is always a string.  If the value you have inside the template is some other type, like a list, it will be converted to a string using some default Go rules, which aren't especially useful in a Kubernetes context.</p>
<p>Helm includes two lightly-documented conversion functions <code>toJson</code> and <code>toYaml</code> that can help here.  Valid JSON is also valid YAML, so one easy approach is just to convert both parts to JSON</p>
<pre class="lang-yaml prettyprint-override"><code>command: {{ toJson .Values.ric_register_avro_job.containers.command }}
args: {{ toJson .Values.ric_register_avro_job.containers.args }}
</code></pre>
<p>or, if you want it to look a little more like normal YAML,</p>
<pre class="lang-yaml prettyprint-override"><code>          command:
{{ .Values.ric_register_avro_job.containers.command | toYaml | indent 12 }}
          args:
{{ .Values.ric_register_avro_job.containers.args | toYaml | indent 12 }}
</code></pre>
<p>or, for that matter, if you're passing a complete container description via Helm values, it could be enough to</p>
<pre class="lang-yaml prettyprint-override"><code>        containers:
          - name: ric_register_avro_job
{{ .Values.ric_register_avro_job.containers | toYaml | indent 10 }}
</code></pre>
<p>In all of these cases, I've put the templating construct starting at the first column, but then used the <code>indent</code> function to correctly indent the YAML block.  Double-check the indentation and adjust the <code>indent</code> parameter.</p>
<p>You can also double-check that what's coming out looks correct using <code>helm template</code>, using the same <code>-f</code> option(s) as when you install the chart.</p>
<p>(In practice, I might put many of the options you show directly into the chart template, rather than making them configurable as values.  The container name, for example, doesn't need to be configurable, and I'd usually fix the command.  For this very specific example you can also set the container's <code>workingDir:</code> rather than running <code>cd</code> inside a shell wrapper.)</p>
