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即学即用(第二版)
140
10
践仍然是通过
YAML
文件以声明式的方式管理部署,然后使用这些文件来更
新部署。如果想扩大部署的规模,则可以通过编辑
YAML
文件增加副本数:
...
spec:
replicas: 3
...
在保存并提交上述更改后,请使用
kubectl apply
命令更新部署:
$
kubectl apply -f kuard-deployment.yaml
这个命令会更新所需的部署状态:将它管理的副本集数量增加到
3
个,并最
终创建一个由部署管理的新
Pod
$
kubectl get deployments kuard
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
kuard 3 3 3 3 4m
10.4.2
更新容器镜像
部署最常见的另一个用途是推出在一个或多个容器中运行的软件的新版本。
为此,你同样应该编辑部署的
YAML
文件,不过这一次你更新的是容器镜像,
而不是副本数:
...
containers:
- image: gcr.io/kuar-demo/kuard-amd64:green
imagePullPolicy: Always
...
我们还将在部署模板中添加一个注释,以记录有关更新的一些信息:
...
spec:
...
template:
metadata:
部署
141
annotations:
kubernetes.io/change-cause: ...
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