Labels
Labels are the metadata that contain identifiable information pertaining to the Kubernetes objects. These are basically key-value pairs that can be attached to objects such as pods. Each key must be unique for an object. Labels contain information that is meaningful to users. Labels can be attached to pods at the time of creation and can also be added or modified during their runtime too. Here is an example of how labels in a YAML file would appear:
metadata: labels: key1: value1 key2: value2
Constraints for Labels
As noted earlier, labels are key-value pairs. There are certain rules that label keys and values should follow. These constraints exist because this way, the queries using labels can be evaluated faster by using optimized data structures and algorithms internally. Kubernetes internally maintains the mappings of labels to corresponding objects using optimized data structures to make these queries...