<p>I want to know what will be the appropriate position of a field in the resource yaml file (say e.g. <code>capabilities</code> field in a <code>pod</code> yaml file).</p>
<p>I can use <code>kubectl explain pod.spec --recursive | less</code> and then <em>search</em> for <code>capabilities</code> and then scroll up to see who is the parent field of <code>capabilities</code> field and so on.</p>
<p>Is there a <em>simpler</em> way to know the hierarchy or parents of field?</p>
<p>I want to see hierarchical output something like this without having to scroll up and figure out manually:</p>
<p><code>pod &gt; spec &gt; containers &gt; securityContext &gt; capabilities</code></p>

Akshay Lokur
<p>I hose this will be helpful,
you can use the <code>yq</code> to output your file in many ways.</p>
<ul>
<li>Get directly what you desire</li>
</ul>
<pre><code>cat my-yaml-file.yaml | yq e '.spec.template.spec.containers'
</code></pre>
<ul>
<li>The <code>-f</code> will output it in a JSON Format.</li>
</ul>
<pre><code>cat my-yaml-file.yaml | yq e -j '.spec.template.spec.containers'
</code></pre>
<ul>
<li>Delete everything after a specific point :</li>
</ul>
<pre><code>cat my-yaml-file.yaml | yq e -j 'del(.spec.template.spec.containers)'
</code></pre>
