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即学即用(第二版)
136
10
replicaset "kuard-1128242161" scaled
再查询一次副本集:
$
kubectl get replicasets --selector=run=kuard
NAME DESIRED CURRENT READY AGE
kuard-1128242161 2 2 2 13m
奇怪。尽管我们将副本集缩小到了一个副本,但其所需状态仍为两个副本。
这是怎么回事?请记住,
Kubernetes
是一个在线自我修复系统。该副本集由
最顶层的部署对象管理。如果你将副本数量调整到
1
,则无法与所需的部署状
态相匹配,因为部署设置的副本数量为
2
。这时,部署控制器会注意到这一点,
并采取措施,以确保观察到的状态与所需状态相符,在这个示例中,它会将
副本数重新调整为两个。
如果想直接管理副本集,则需要删除部署(请不要忘记将
--cascade
设置为
false
,否则会连副本集和
Pod
一起删除)。
10.2
创建部署
我们再三强调,你应该优先选择声明式的方式来管理
Kubernetes
配置。因此,
你也应该通过磁盘上的
YAML
JSON
文件维护部署的状态。
首先,将部署下载到
YAML
文件中:
$
kubectl get deployments kuard --export -o yaml > kuard-deployment.yaml
$
kubectl replace -f kuard-deployment.yaml --save-config ...
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