<p>I have a pod which I want to insert the following annotation for:</p>
<pre><code>annotationexample: |
      [
        {
          &quot;a&quot;: &quot;b&quot;,
          &quot;c&quot;: &quot;d&quot;,
          &quot;e&quot;: [
            &quot;f&quot;
          ]
        }
      ]
</code></pre>
<p>When I try to apply this using <code>kubectl annotate --overwrite</code> I get an error saying <code>name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character</code>. The <code>[</code>, <code>]</code>, <code>{</code> and <code>}</code> characters are causing issues, but I have previously been able to apply the annotation through a helm chart. But I am seeking a solution through just using kubectl to only edit annotations. I don't want to create a new pod from a yaml file (<code>kubectl apply -f</code>) as then extra fields are added.</p>

Sabo Boz
<p>It sounds like you have an error in your command line. If you want to set that annotation on a resource, you would run a command like this:</p>
<pre><code>kubectl annotate pod/example annotationexample='[
  {
    &quot;a&quot;: &quot;b&quot;,
    &quot;c&quot;: &quot;d&quot;,
    &quot;e&quot;: [
      &quot;f&quot;
    ]
  }
]
'
</code></pre>
<p>That results in:</p>
<pre><code>$ kubectl get pod example -o yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    annotationexample: |
      [
        {
          &quot;a&quot;: &quot;b&quot;,
          &quot;c&quot;: &quot;d&quot;,
          &quot;e&quot;: [
            &quot;f&quot;
          ]
        }
      ]
.
.
.
</code></pre>
