你正在查看的文档所针对的是 Kubernetes 版本: v1.25
Kubernetes v1.25 版本的文档已不再维护。你现在看到的版本来自于一份静态的快照。如需查阅最新文档,请点击 最新版本。
LabelSelector
import "k8s.io/apimachinery/pkg/apis/meta/v1"
标签选择器是对一组资源的标签查询。
matchLabels 和 matchExpressions 的结果按逻辑与的关系组合。
一个 empty 标签选择器匹配所有对象。一个 null 标签选择器不匹配任何对象。
- matchExpressions ([]LabelSelectorRequirement) - matchExpressions是标签选择器要求的列表,这些要求的结果按逻辑与的关系来计算。- matchExpressions.key (string), 必填 - 补丁策略:按照键 - key合并- key是选择器应用的标签键。
 - matchExpressions.operator (string),必填 - operator表示键与一组值的关系。有效的运算符包括- In、- NotIn、- Exists和- DoesNotExist。
 - matchExpressions.values ([]string) - values是一个字符串值数组。如果运算符为- In或- NotIn,则- values数组必须为非空。- 如果运算符是 - Exists或- DoesNotExist,则- values数组必须为空。- 该数组在策略性合并补丁(Strategic Merge Patch)期间被替换。 
 
- matchLabels (map[string]string) - matchLabels是 {- key,- value} 键值对的映射。- matchLabels映射中的单个 {- key,- value} 键值对相当于- matchExpressions的一个元素,其键字段为- key,运算符为- In,- values数组仅包含- value。- 所表达的需求最终要按逻辑与的关系组合。 
This page is automatically generated.
If you plan to report an issue with this page, mention that the page is auto-generated in your issue description. The fix may need to happen elsewhere in the Kubernetes project.