探针包含三种:
- Liveness存活探针:
- 判断容器是否处于运行状态
- Readness就绪探针:
- 判断服务是否正常工作
- Startup启动检测:
- 1.16版本后加入,针对容器内应用服务是否已经启动监控,如果配置了该探针,则会先禁用其他探针,直到成功为止,成功后将不再进行探测
Liveness存活探针在容器启动时标记为成功,防止还没启动完成就被kill掉
Readness就绪探针在容器启动时标记为失败,防止还没启动完成就接收流量,避免请求失败
只配置Readness探针无法触发重启
探针类型:
ExecAction:容器内执行shell命令并返回0
TCPSocketAction:测试容器IP端口是否打开
HTTPGetAction:通过容器IP端口路径执行HTTP Get请求,200<=返回值<400
示例:
spec:
containers:
- name: xxx
# startupProbe 健康检测
startupProbe:
failureThreshold: 3 # 检测失败3次表示未就绪
httpGet: # 请求方式
path: /ready # 请求路径
port: 8182 # 请求端口
scheme: HTTP # 请求协议
periodSeconds: 10 # 检测间隔时间
successThreshold: 1 # 检测成功1次表示就绪
timeoutSeconds: 1 # 检测超时时间
# livenessProbe 健康检测
livenessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 30 # 初始化时间,此时间内不开始检测
periodSeconds: 10 # 检测间隔时间
successThreshold: 1 # 检查成功1次表示就绪
failureThreshold: 3 # 检查失败3次表示未就绪
timeoutSeconds: 1 # 超时时间
# readinessProbe 将康检测
readinessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 1