<p>What I'm trying to achieve is to set an array of values into the hosts field in my ingress chart similar to:</p>
<pre><code>spec:
  tls:
    hosts:
      - domain1
      - domain2
      - domain3
</code></pre>
<p>The problem I'm facing is that I have a default domain (domain1) and an array of extra domains (domain2, domain3) which is not of a fixed length.</p>
<p>What I tried was to iterate through the array along the default value</p>
<pre><code>- hosts:
  - {{.Values.domain}}
  {{- range $key, $val := .Values.regionalDomain }}
    - {{ $val }}
  {{- end }}
</code></pre>
<p>But I get errors similar to: <code>spec.tls[0].hosts: Invalid value: &quot;domain1 - domain2 - domain3&quot;: a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')</code></p>

Timotei Manolache
<p>I find it easier work with data in templates where possible, rather than trying to format yaml.</p>
<p><a href="https://helm.sh/docs/chart_template_guide/function_list/#values" rel="nofollow noreferrer"><code>values</code></a> can pull information out of a dictionary into a list.<br>
<a href="https://helm.sh/docs/chart_template_guide/function_list/#prepend-mustprepend" rel="nofollow noreferrer"><code>prepend</code></a> can add to the list.<br>
<a href="https://helm.sh/docs/chart_template_guide/function_list/#tojson-musttojson" rel="nofollow noreferrer"><code>toJson</code></a> deals with the formatting.</p>
<pre><code>hosts: {{ prepend (values .Values.regionalDomain) .Values.domain | toJson }}
</code></pre>
