<p>is it possible in Kubernetes values to refer to value in the same file? I'm doing a for loop and most env vars are fine but this one depends on some other val and need to duplicate/refer to it somehow inside values;</p>

<pre><code>image:
  repository: nginx
  tag: stable

someCustomVal:
- name: x
  value: xx
- name: y
  value: yy
- name: z
  value: {{ .Values.image.tag }}
</code></pre>

<p>btw above config doesn't work but looking for equivalent; I could just do the z value outside of for loop in the deployment but that wouldn't look nice so looking for alternative of referecnce</p>

CptDolphin
<p>This isn't Kubernetes-specific, you can do this with <a href="https://yaml.org/spec/1.2/spec.html#id2785977" rel="nofollow noreferrer">YAML anchors</a>:</p>

<pre><code>$ cat example.yaml
image:
  repository: nginx
  tag: &amp;imagetag stable

someCustomVal:
- name: x
  value: xx
- name: y
  value: yy
- name: z
  value: *imagetag

$ ruby -ryaml -rpp -e'pp YAML.load_file("example.yaml")'
{"image"=&gt;{"repository"=&gt;"nginx", "tag"=&gt;"stable"},
 "someCustomVal"=&gt;
  [{"name"=&gt;"x", "value"=&gt;"xx"},
   {"name"=&gt;"y", "value"=&gt;"yy"},
   {"name"=&gt;"z", "value"=&gt;"stable"}]}
</code></pre>
