<p>I am New at Helm , so sorry if I am not clear , of if I use the wrong terms.</p>
<p>I am trying to iterate over a list of IP , feed them in a range and create a array of ip for a headless service.</p>
<p>Here is my template:</p>
<pre><code>kind: Endpoints
apiVersion: v1
metadata:
 name: backend-modbile-db-service
 namespace: {{ .Release.Namespace }}
subsets:
 - addresses:
     {{- range $key, $val := .Values.DatabaseEndpoints }}
      - {{ $key }}: {{ $val }}
     {{- end }}
   ports:
     - port: {{ .Values.DatabasePort| default 5984 }}
       name: backend-mobile-db-service
</code></pre>
<p>and the Value.yaml concerning theses IP look like this:</p>
<pre><code>#backend-mobile-db-service

DatabasePort: 5984
DatabaseEndpoints:
  ip: 192.168.0.50
  ip: 192.168.0.51
  ip: 192.168.0.52
  ip: 192.168.0.55
  ip: 192.168.0.56
  ip: 192.168.0.57
</code></pre>
<p>I expected that the template would take the value and index  and put them in the array of my service , but it only take the last key:value pair in the Value.yaml map:</p>
<pre><code># Source: backend-mobile/templates/backend-mobile-db-service.yaml
kind: Endpoints
apiVersion: v1
metadata:
 name: backend-modbile-db-service
 namespace: default
subsets:
 - addresses:
      - ip: 192.168.0.57
   ports:
     - port: 5984
       name: backend-modbile-db-service
</code></pre>
<p>Whereas , I expected an output like so:</p>
<pre><code># Source: backend-mobile/templates/backend-mobile-db-service.yaml
kind: Endpoints
apiVersion: v1
metadata:
 name: backend-modbile-db-service
 namespace: default
subsets:
 - addresses:
      - ip: 192.168.0.50
      - ip: 192.168.0.51
       [...]
      - ip: 192.168.0.52
   ports:
     - port: 5984
       name: backend-modbile-db-service
</code></pre>
<p>Where I the error I made ?
Thanks in advance :)</p>

<p>Because you are overwriting ip again and again, so you only see the last one. If you want to declare an array of ip, you should do:</p>
<pre><code>DatabaseEndpoints:
  ip:
  - 192.168.0.50
  - 192.168.0.51
  - 192.168.0.52
  - 192.168.0.55
  - 192.168.0.56
  - 192.168.0.57
</code></pre>
<p>Therefore your template should be changed to like below:</p>
<pre><code>subsets:
 - addresses:
     {{- range .Values.DatabaseEndpoints.ip }}
      - ip: {{ . }}
     {{- end }}
</code></pre>
