<p>In deployment.yaml in:</p>
<pre><code>      containers:
        - name: {{ .Values.stand }}-container
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}&quot;
          {{- if $.Values.command }}
          command:
            {{ .Values.command.cmd }}
          {{- end }}
          {{- if or $.Values.env $.Values.envSecrets }}
</code></pre>
<p>I tried adding:</p>
<pre><code>{{- if $.Values.command }}
command:
  {{ .Values.command.cmd }}
{{- end }}
</code></pre>
<p>Then I tried to pass the command:</p>
<pre><code>helm install NAME nexus/stand 
      --set 'command.cmd[0]=- /bin/sh' \
      --set 'command.cmd[1]=- -с' \
      --set 'command.cmd[2]=- |' \
      --set 'command.cmd[3]=while true; do' \
      --set 'command.cmd[4]=sleep 60;' \
      --set 'command.cmd[5]=done'
</code></pre>
<p>but nothing works.</p>
<p>How to via --set pass?</p>
<pre><code>command:
- /bin/sh
- -c
- |
  while true; do
    sleep 60;
  done
</code></pre>
<p>Thank you.</p>

Maksim
<p>Helm does not support setting non-existent array elements, you can assign values by passing the entire array or set the corresponding number of elements first, and then modify it by --set cmd[i]=xxx.</p>
<hr />
<p>First of all, in the deployment.yaml file, the <code>Values.command.cmd</code> field should not be quoted directly, as an array needs to be quoted in the following way: <code>{{ toYaml … }}</code></p>
<p>deployment.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>      containers:
        - name: {{ .Values.stand }}-container
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}&quot;
          {{- if $.Values.command }}
          command:
            {{ toYaml .Values.command.cmd | nindent 12 }}
          {{- end }}
          {{- if or $.Values.env $.Values.envSecrets }}
</code></pre>
<p>Then if you use the values.yaml file method to pass in the parameters, you should write like this here：</p>
<p>values.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>command:
  cmd:
    - /bin/sh
    - -c
    - while true; do sleep 60; done
</code></pre>
<p>Finally, if you want to set by <code>--set</code>, you need to pass array values you can use curly braces (unix shell require quotes):</p>
<pre class="lang-yaml prettyprint-override"><code>--set command.cmd={&quot;/bin/sh&quot;\,&quot;-c&quot;\,&quot;while true; do sleep 60; done&quot;}
</code></pre>
<p><strong>Notice!!!</strong></p>
<p>The separator of the array elements <code>,</code> you must remember to add a <code>\</code></p>
