<p>I have this YAML structure:</p>
<pre><code>metadata:
  annotations:
  creationTimestamp: &quot;2021-04-20T15:18:50Z&quot;
  labels:
    billing: mybilling
    beta.kubernetes.io/os: linux
</code></pre>
<p>I'm trying to access it over my script but I could not access the &quot;beta.kubernetes.io/os&quot; because the special chars.</p>
<pre><code>        {{$os_version := .metadata.labels.beta.kubernetes.io/os }} --&gt; failed
        {{$os_version := .metadata.labels.&quot;beta.kubernetes.io/os&quot; }} --&gt; failed
        {{$os_version := .metadata.labels.beta\.kubernetes\.io\/os }} --&gt; failed

        {{$os_version := .metadata.labels.billing }} --&gt; success
</code></pre>
<p>How to access the metadata &quot;.metadata.labels.beta.kubernetes.io/os&quot;? How to scape this special chars?</p>

Ramon Lucas
<p>The standard library already provides the <a href="http://golang.org/pkg/text/template/#hdr-Functions" rel="nofollow noreferrer">index function</a></p>
<pre><code>{{ index .metadata.labels &quot;beta.kubernetes.io/os&quot; }}
</code></pre>
<p>In my case:</p>
<pre><code>{{$os_version := index .metadata.labels &quot;beta.kubernetes.io/os&quot; -}}  --&gt; works!!!
</code></pre>
