<p>Is it possible to add a custom field to a kubernetes resource (without creating a CRD)?</p>
<p>I want to create a secret but add a custom field like an ID what is not used by k8s but from another application.</p>
<p>When I add the field in metadata or just at the beginning, <code>kubectl apply</code> fails with</p>
<blockquote>
<p>error validating data: [ValidationError(Secret): unknown field &quot;custom_field&quot; in io.k8s.api.core.v1.Secret</p>
</blockquote>

Patrick Derckx
<p>No. There's a schema to comply with, depending on which object you work with. Most of the time, you would not be able to add arbitrary keys like this.</p>
<p>A way to add custom IDs to native Kubernetes resources may be to use some annotation (or label):</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  annotations:
    example.com/custom-field: my-value
  name: foo
....
</code></pre>
