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即学即用(第二版)
52
4
道结合使用的情况,例如
kubectl ... | awk ...
。如果指定
--no-headers
标志,则
kubectl
不会显示方便人类阅读的表头。
另一个常见的任务是提取对象的特定字段。
kubectl
使用
JSONPath
查询语言
来选择返回对象的字段。有关
JSONPath
的完整说明不在本章范围之内,在此
我们仅举一个简单的例子,通过以下命令提取并输出
Pod
IP
地址:
$
kubectl get pods my-pod -o jsonpath --template={.status.podIP}
如果你对特定对象的详细信息感兴趣,则可以使用
describe
命令:
$
kubectl describe <
资源名称
> <
对象名称
>
这个命令将输出方便人类阅读的多行信息,其中不仅包括命令中指定的对象,
而且还包括
Kubernetes
集群中任何其他相关的对象和事件。
4.4
创建、更新和销毁
Kubernetes
对象
Kubernetes API
中的对象以
JSON
YAML
文件的形式表示。这些文件由服
务器在响应查询时返回,或者作为
API
请求的一部分发送到服务器。你可以
使用这些
YAML
JSON
文件在
Kubernetes
服务器上创建、更新或删除对象。
假设文件
obj.yaml
中存储了一个简单的对象,那么就可以通过运行以下命令,
使用
kubectl
Kubernetes
中创建该对象:
$
kubectl apply -f obj.yaml
请注意,你无需指定对象的资源类型,命令会从目标文件中获得。 ...
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