What is Annotations in Kubernetes?
There are two way using you can attach metadata to Kubernetes objects.
- labels
- annotations
Kubernetes annotations is used to attach arbitrary non-identifying metadata to objects. Clients such as tools and libraries can retrieve this metadata.
In contrast, annotations are not used to identify and select objects. The metadata in an annotation can be small or large, structured or unstructured, and can include characters not permitted by labels.
Annotations, like labels, are key/value maps:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: ./kompose convert
kompose.version: “”
FORMAT
"metadata": {</p> <p class="p1"><span class="Apple-converted-space"> </span>"annotations": {</p> <p class="p1"><span class="Apple-converted-space"> </span>"key1" : "value1",</p> <p class="p1"><span class="Apple-converted-space"> </span>"key2" : "value2"</p> <p class="p1"><span class="Apple-converted-space"> </span>}</p> <p class="p1">}</p>
Here are some examples of information that could be recorded in annotations:
- Build, release, or image information like timestamps, release IDs, git branch, PR numbers, image hashes, and registry address.
- Pointers to logging, monitoring, analytics, or audit repositories.
More
https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/