官术网_书友最值得收藏!

Label and selector

Labels are sets of key/pair values that attach to objects. They're designed to provide meaningful, identifying information about objects. Common usages are to indicate the name of the micro-service, the tier, the environment, and the software version. Users can define meaningful labels that could be used with selectors later. The syntax of labels in an object spec is as follows:

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

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

  • Equality-based requirements
  • Set-based requirements

Equality-based requirements support the following operators: =, ==, and !=. Take the following diagram as an example: if the selector is chapter=2,version!=0.1, the result will be object C. If the requirement is version=0.1, the result will be object A and object B:

Selector example

If we write the requirement in the supported object spec, it'll be as follows:

selector:
$key1: $value1

Set-based requirement supports in, notin, and exists (for key only). For example, if the requirement is chapter in (3, 4),version, then object A will be returned. If the requirement is version notin (0.2), !author_info, the result will be object A and object BThe following example shows an object spec that uses set-based requirements:

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

The requirements of matchLabels and matchExpressions are combined together. This means that the filtered objects need to be true for both requirements.

主站蜘蛛池模板: 延安市| 沽源县| 尉氏县| 乌兰浩特市| 平乡县| 杂多县| 读书| 华安县| 吉安市| 霍山县| 太谷县| 阿鲁科尔沁旗| 彭泽县| 南召县| 象山县| 昔阳县| 蓝山县| 莱州市| 二连浩特市| 辽阳县| 会宁县| 赫章县| 连江县| 琼中| 平和县| 仲巴县| 阜新| 遂昌县| 定陶县| 九龙城区| 台山市| 绥化市| 万州区| 衡山县| 遵义县| 泾阳县| 汉中市| 澎湖县| 井陉县| 留坝县| 蒙山县|