<p>What is the meaning of value key being under the &quot;name&quot; list but with no dash before it? (How should I read and understand this)</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: postgres
  labels:
    tier: db-tier
spec:
  containers:
    - name: postgres
      image: postgres
      env:
        - name: POSTGRES_PASSWORD
          value: mysecretpassword
</code></pre>
<p>Doing this instead will not result in a valid K8s YAML. Why is that ?</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: postgres
  labels:
    tier: db-tier
spec:
  containers:
    - name: postgres
      image: postgres
      env:
        - name: POSTGRES_PASSWORD
        - value: mysecretpassword
</code></pre>

<p>If we considered your suggestion on contrary to actual solution than kubernetes treat your format of</p>
<pre><code>env:
    - name: POSTGRES_PASSWORD
    - value: mysecretpassword
    - name: variable
    - value: answer
</code></pre>
<p>as:-</p>
<pre><code>env: [{name:POSTGRES_PASSWORD}, {value:mysecretpassword}, {name:variable}, {value:answer}]
</code></pre>
<p>In this way, K8s will not able to map actual object of key value pair.</p>
<p>So the actual format to define array in yaml, or we can say the syntax to define an array in yaml is below.</p>
<p>For example:-</p>
<pre><code>env:
    - name: POSTGRES_PASSWORD
      value: mysecretpassword
    - name: POSTGRES_USER
      value: root
</code></pre>
<p>This will be treated as:-</p>
<pre><code>env: [{name:POSTGRES_PASSWORD, value:mysecretpassword}, {name:POSTGRES_USER, value:root}]
</code></pre>
<p>For more help you can visit <a href="https://stackoverflow.com/questions/23657086/yaml-multi-line-arrays/33136212">so link 1</a> and <a href="https://stackoverflow.com/questions/33989612/yaml-equivalent-of-array-of-objects-in-json">so link 2</a>.</p>
