Kubernetes Labels and Annotations
A label is a key/value pair contains identifying information used to organize and categorize (scope and select) objects.
Labels is a mechanism to define loose couplings.
The structure of keys and values is constrained, so they can be evaluated quickly.
- Label syntax and character set: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set.
An annotation contains non-identifying information. The information exposed by annotations is not used internally by Kubernetes. Is not queryable, cannot be used in selectors. The annotation keys and values are not constrained. Stored in .metadata.annotations.
apiVersion: apps/v1 kind: Deployment spec: template: metadata: annotations: sidecar.istio.io/inject: "true" ...
Setting an annotation on Deployment itself, in the Deployment's metadata, makes it propagate to the ReplicaSet.