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即学即用(第二版)
服务发现
95
外,当然你可以使用完整的服务名称(
alpaca-prod.default.svc.cluster.
local.
)。你可以在“
DNS Query
”页面中,拿
kuard
做各种尝试。
7.2.2
就绪检查
通常,应用程序刚刚启动时还无法处理请求。一般会有一些初始化的过程,
可能需要不到一秒,也可能需要几分钟的时间。服务对象的一个特点是它会
通过就绪检查跟踪哪些
Pod
已准备就绪。下面,我们来修改我们的部署,将
Pod
的就绪检查添加进去(请参见第
5
章):
$
kubectl edit deployment/alpaca-prod
这个命令将获取
alpaca-prod
部署的当前版本,并显示在编辑器中。在保存
并退出编辑器后,它会把对象写回到
Kubernetes
。这种方法可以快速编辑对
象而无需将其保存到
YAML
文件。
我们来添加以下部分:
spec:
...
template:
...
spec:
containers:
...
name: alpaca-prod
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 2
initialDelaySeconds: 0
failureThreshold: 3
successThreshold: 1
这段代码的作用是设置部署将要创建的
Pod
,以便通过
HTTP GET
访问端口
8080
上的
/ready
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