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即学即用(第二版)
Pod
69
5.6
健康检查
将应用程序作为容器在
Kubernetes
中运行时,
Kubernetes
会自动执行进程健
康检查,以确保应用程序处于活动状态。这种健康检查只能确保应用程序的
主进程始终处于运行状态。如果主进程没有运行,
Kubernetes
就会重启应用
程序。
然而,在大多数情况下,简单的进程检查还不够。例如,进程陷入死锁时,
尽管无法处理请求,但进程健康检查仍然会认为应用程序正常,因为进程仍
在运行。
为了解决这个问题,
Kubernetes
引入了应用程序的存活健康检查。存活健康
检查会运行应用程序特有的逻辑(例如加载网页),以此来验证应用程序不
仅仍在运行,而且运行很正常。由于这些存活健康检查是各个应用程序专用的,
因此你必须在
Pod
清单中定义它们。
5.6.1
存活探针
kuard
进程启动并开始运行后,我们需要一种方法来确认它是否处于健康
状态,不需要重启。存活探针是针对每个容器定义的,这意味着
Pod
内的每
个容器都需要分别进行健康检查。在示例
5-2
中,我们向
kuard
容器添加了
一个存活探针,该探针会针对容器的
/healthy
路径发送
HTTP
请求。
示例
5-2
kuard-pod-health.yaml
apiVersion: v1
kind: Pod
metadata:
name: kuard
spec:
containers:
- image: gcr.io/kuar-demo/kuard-amd64:blue
name: kuard
livenessProbe:
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