Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
86
6
6
-
2
:选择器操作符
操作符
描述
key=value key
的值等于
value
key!=value key
的值不等于
value
key in (value1, value2) key
的值属于集合
(value1, value2)
key notin (value1, value2) key
的值不属于集合
(value1, value2)
key key
已被设置
!key key
未被设置
例如,查询某个没有被设置的键(例如
canary
):
$
kubectl get deployments --selector='!canary'
同样,你可以组合使用正反选择器,如下所示:
$
kubectl get pods -l 'ver=2,!canary'
6.1.4 API
对象中的标签选择器
Kubernetes
对象使用标签选择器引用其他对象组。上一节中使用了简单的字
符串,而下面我们将使用一种需要解析的结构。
由于历史原因(
Kubernetes
不希望破坏
API
的兼容性),
Kubernetes
提供了
两种形式。大多数对象都支持较新且功能更强大的选择器运算符。
选择器
app=alpaca,ver in (1, 2)
可以转化为:
selector:
matchLabels:
app: alpaca
matchExpressions:
- {key: ver, operator: In, values: [1, 2]}
❶
紧凑的
YAML
语法。该行为列表
matchExpressions
中的一项,它定义了 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762