I want to add a sub field to a standard k8s object, such as a V1Deployment or V1Secret, is this possible, and if so how?
I looked for commands which might allow me to add a sub field, but couldn't find any. I also tried using a yaml file and patching existing objects by including the sub field I wanted in the object's body, but (as exacted) this gave an error due to the sub field not being recognized.
You can use annotations to attach arbitrary metadata to objects, for example:
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"annotations": {
"my-key": "my-value"
}
}
...
Official documentation for reference: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/