|
| 1 | +--- |
| 2 | +--- |
| 3 | + |
| 4 | +{% capture overview %} |
| 5 | +You can use Kubernetes annotations to attach arbitrary non-identifying metadata |
| 6 | +to objects. Clients such as tools and libraries can retrieve this metadata. |
| 7 | +{% endcapture %} |
| 8 | + |
| 9 | +{% capture body %} |
| 10 | +### Attaching metadata to objects |
| 11 | + |
| 12 | +You can use either labels or annotations to attach metadata to Kubernetes |
| 13 | +objects. Labels can be used to select objects and to find |
| 14 | +collections of objects that satisfy certain conditions. In contrast, annotations |
| 15 | +are not used to identify and select objects. The metadata |
| 16 | +in an annotation can be small or large, structured or unstructured, and can |
| 17 | +include characters not permitted by labels. |
| 18 | + |
| 19 | +Annotations, like labels, are key/value maps: |
| 20 | + |
| 21 | + "annotations": { |
| 22 | + "key1" : "value1", |
| 23 | + "key2" : "value2" |
| 24 | + } |
| 25 | + |
| 26 | +Here are some examples of information that could be recorded in annotations: |
| 27 | + |
| 28 | +* Fields managed by a declarative configuration layer. Attaching these fields |
| 29 | + as annotations distinguishes them from default values set by clients or |
| 30 | + servers, and from auto-generated fields and fields set by |
| 31 | + auto-sizing or auto-scaling systems. |
| 32 | + |
| 33 | +* Build, release, or image information like timestamps, release IDs, git branch, |
| 34 | + PR numbers, image hashes, and registry address. |
| 35 | + |
| 36 | +* Pointers to logging, monitoring, analytics, or audit repositories. |
| 37 | + |
| 38 | +* Client library or tool information that can be used for debugging purposes: |
| 39 | + for example, name, version, and build information. |
| 40 | + |
| 41 | +* User or tool/system provenance information, such as URLs of related objects |
| 42 | + from other ecosystem components. |
| 43 | + |
| 44 | +* Lightweight rollout tool metadata: for example, config or checkpoints. |
| 45 | + |
| 46 | +* Phone or pager numbers of persons responsible, or directory entries that |
| 47 | + specify where that information can be found, such as a team web site. |
| 48 | + |
| 49 | +Instead of using annotations, you could store this type of in information in an |
| 50 | +external database or directory, but that would make it much harder to produce |
| 51 | +shared client libraries and tools for deployment, management, introspection, |
| 52 | +and the like. |
| 53 | + |
| 54 | +{% endcapture %} |
| 55 | + |
| 56 | +{% capture whatsnext %} |
| 57 | +Learn more about [Labels and Selectors](/docs/user-guide/labels/). |
| 58 | +{% endcapture %} |
| 59 | + |
| 60 | +{% include templates/concept.md %} |
0 commit comments