September 8, 2019 ~ 2 min read

Labels and selectors


Labels are a set of key/pair values, used to attach to objects. Labels are designed to specify meaningful, identifying information for the object. Common usage is micro-service name, tier, environment, and software version. Users could define meaningful labels that could be used with selector later.

Labels syntax in object spec is:

labels:
    $key1: $value1 $key2: $value2

Along with label, label selector is used to filter the set of objects. Separated by commas, multiple requirements will be joined by the AND logical operator. There are two ways to filter:

selector:
    matchLabels: $key1: $value1 matchExpressions: {key: $key2, operator: In, values: [$value1, $value2]}

Sebastian BolaƱos

Hi, I'm Sebastian. I'm a software developer from Costa Rica. You can follow me on Twitter. I enjoy working on distributed systems.