kubernetes annotations

Annotations are not used to describe objects, i.e. it’s not possible to select objects using annotations. They are used to contain metadata that are greater that kubernetes label size constraint (63 characters + forbidden characters).

$ # add annotation
$ kubectl annotate pod light-sleeper k8s.louis.lin/created-by=foobar
pod "light-sleeper" annotated
 
$ # display annotation
$ kubectl describe pod light-sleeper | grep Annotations
Annotations: k8s.louis.lin/created-by=foobar

Example to use annotations

  • build number from the CI/CD
  • release date
  • git branch
  • MR id
  • docker image hash
  • list of dependencies (services)
  • source (who generates the object and when)
  • owner team (name, phone, email, channel)