当前位置:网站首页>容器健康检查解析
容器健康检查解析
2022-07-16 02:31:00 【江小南】
健康检查方式
在kubernetes中,我们经常会看到健康检查相关的配置。一般有两种健康检查方式:存活性健康检查和可用性健康检查,也可以叫做存活探针或者就绪探针。
通过一段工作中使用到的配置给大家作以讲解。
livenessProbe:
failureThreshold: 3
httpGet:
path: /sams/webapi/health
port: 19201
scheme: HTTP
initialDelaySeconds: 120
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 30
readinessProbe:
failureThreshold: 3
httpGet:
path: /sams/webapi/health
port: 19201
scheme: HTTP
initialDelaySeconds: 120
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 30
字段含义
从yaml配置可以看出,存活性健康检查和可用性检查配置基本相似,每个字段所表示的含义也相同。
| 字段 | 含义 |
|---|---|
| ailureThreshold | 不正常阈值。超过此值表示容器不健康 |
| httpGet | 采用http健康检查的方式 |
| path | 服务器上的访问URI |
| port | 容器上要访问端口号 |
| scheme | 用于连接host的协议(HTTP或HTTPS),默认为HTTP |
| initialDelaySeconds | 等待时间。从容器启动开始算起 |
| periodSeconds | 每次探测时间间隔 |
| successThreshold | 正常阈值,失败后检查成功的最小次数,即从错误到正确要多少次表示健康 |
| httpHeaders | 自定义请求头 |
三种检查方式
kubernetes中有三种健康检查的方式。上面示例中采用的是httpGet的方式,其他两种为TCP和EXEC。这三种健康检查的配置基本相同。
区别:
http(httpGet)检查方式会向容器中运行的服务发送HTTP GET请求,请求某个端口(port)下的资源(path),返回任何大于等于200且小于400的值,均表示健康,反之为不健康。
TCP(tcpSocket)检查方式将连接到容器的某个端口(port),如果探测成功,返回值为0,则该容器是健康的,反之为不健康。
EXEC检查方式会在容器中执行执行特定的命令(command),如果命令执行成功,则返回0,那么就认为容器是健康的,反之为不健康。
检查结果:
对于两种检查检查方式,有三种检查结果。
| 结果 | 含义 |
|---|---|
| Success | 通过了检查 |
| Failure | 未通过检查 |
| Unknown | 未能进行检查,因此不采取任何措施 |
梳理总结
存活性健康检查在检测失败后会重启容器,可用性健康检查失败后隔离服务(没有流量),不会重启。其实容器的重启并不是由健康检查决定,而是由容器的重启策略restartPolicy决定的。
如果一个容器不包含存活探针,则Kubelet认为容器的存活探针的返回值永远成功。
边栏推荐
- 从应用到底层:36张图带你进入Redis世界(上)
- Excel-vba quick start (VII. Get cell objects)
- 接口自动化测试:Postman实战教程
- Redis installation (Windows) and common usage methods
- Luogu questionnaire - greed
- Opensource knowledge: embedded software list
- openEuler 知:日志查找技巧
- [wechat applet] simple and easy-to-use icon (94/100)
- Detailed explanation of assembly language programming skills (with examples)
- Openeuler knowledge: management strategy
猜你喜欢

How to view RT thread documents, engineering establishment of RT and rapid construction of BSP

JupyterLab安装

【MOCO基础】Attention, learn to solve routing problems(Wouter Kool, 2018)
![[wechat applet] simple and easy-to-use icon (94/100)](/img/2b/11ca1196531fe837ba42142491e896.png)
[wechat applet] simple and easy-to-use icon (94/100)

网安学习-权限提升

ThreadX kernel source code analysis (SMP) - thread execution core remap

openEuler 知:repo

Introduction, installation et utilisation des outils en ligne de commande terraform

线代初等变换,矩阵的秩

Terraform命令行工具介绍、安装、使用
随机推荐
openEuler 知:管理策略
PostgreSQL weekly person interview
Introduction, installation et utilisation des outils en ligne de commande terraform
网安学习-权限提升
Summary of autumn recruitment problems
HDOJ-2057(A + B Again)
Interview frequency: how does MySQL ensure high availability?
Rust language -- xiaoxiaobai's introductory learning 10
Openeuler knowledge: official Community
今晚8点! LightDB PG分布式数据库技术创新与实践”
AcWing 368. Galaxy problem solution (strongly connected components as difference constraints)
DINO&PAWS
FreeRTOS personal notes - lists and list items
【对象转换】vo2dto使用
Rust语言——小小白的入门学习10
技术分享| 快对讲-5G对讲
IntelliJ tips
[noun] LTS
Ftxui basic notes (Hello World)
You can't answer these 20 classic redis interview questions yet, and the interviewer doesn't even look at you