9.2Ready检查

kubernetes通过ready检查,检查程序是否准备好了,是否可以正常访问了,若程序已ready,则该pod将挂到负载均衡上去

ready检查通健康检查一样,同样支持基于bash、http、tcp的策略

基于bash的策略

readinessProbe:
  exec:
    command:
    - /bin/sh
    - -c
    - ps -ef|grep java|grep -v grep

基于http的策略

基于http的策略:kubernetes通过发起http请求,若http的响应值为200,则认为检查通过,否则失败。

设置http策略,可按照如下方式设置deployment:

readinessProbe:
  httpGet:
    path: /examples/index.html
    port: 8080
    scheme: HTTP

注意:设置initialDelaySeconds的值时,尽量大于pod的预计启动时间

基于TCP的健康检查

基于tcp的策略:kubernetes判断port是否开启,若port开启,则认为检查通过,否则失败。

扩展

readinessProbe的其他参数

readiness 决定了deployment 的AVAILABLE字段,已ready,则AVAILABLE为1,否则为0

Last updated

Was this helpful?