We saw an introduction to labels in our article here. In this article let’s try to understand the differences between labels and annotation & when to use one over another.

Let’s quickly summarize what we learnt about labels

Why use Labels in K8s?

Labels allow K8s to group a set of related resources(example:- all prod resources). Selectors are used to query those labels(example:- get me all prod resources). Official Docs here. Something to note, at the time of writing of this article, below are the restrictions on how a label must be defined in K8s

Valid label value:

  • must be 63 characters or less (cannot be empty),
  • must begin and end with an alphanumeric character ([a-z0–9A-Z]),
  • could contain dashes (-), underscores (_), dots (.), and alphanumerics between.

#kubernetes

K8s Labels &Annotations
1.20 GEEK