- DevOps with Kubernetes
- Hideto Saito Hui Chuan Chloe Lee Cheng Yang Wu
- 255字
- 2021-07-02 13:41:54
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:

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 B. The 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.
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Visual Basic .NET程序設計(第3版)
- Django+Vue.js商城項目實戰
- 軟件項目估算
- Swift語言實戰精講
- Visual Basic程序設計
- Visual Basic語言程序設計基礎(第3版)
- Python預測分析與機器學習
- Microsoft HoloLens By Example
- Android嵌入式系統程序開發(基于Cortex-A8)
- Learning Alfresco Web Scripts
- JavaScript Mobile Application Development
- Java Script從入門到精通(第5版)
- Serverless工程實踐:從入門到進階
- Switching to Angular 2