Updating An Annotation
For updating an annotation we the –override flag in the annotate command
kubectl annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]
For simpler explanation, since we are using a service, we can use this command for updating an annotation
kubectl annotate service [NAME] --override [KEY]='[VALUE]
For example, in order to update the description annotation, enter the following command in your terminal
kubectl annotate service example --overwrite description='this is the new description'
And now if you check the information for the service by using “kubectl describe” command like before:
kubectl describe service example
You will get the following output with the updated annotation:
How to Use Kubernetes Annotations?
Annotations are key-value pairs that are used to attach non-identifying metadata to Kubernetes objects. Various tools that are built over Kubernetes use this metadata attached by annotations to perform actions or enhance resource management. Labels and Annotations are used to attach metadata to Kubernetes objects. This makes annotations important for working with Kubernetes clusters. To learn more about Kubernetes cluster and its architecture refer to Kubernetes – Architecture.