Liveness and readiness

1. 什么是Liveness?什么只readiness?

如:liveness:   

K8S 通过Liveness探针来检测容器/pod是否在正常运行,如果探测失败,会主动重启容器/pod

readiness与liveness类似,只有容器/pod满足条件时,才会作为后端的endpoint point提供服务,readiness没有就绪时,容器/pod只会按计划启动,但并不会提供服务。

readiness与liveness类似,三种方式。

2. 三种探测方式

a. exec

如:

livenessProbe:
    exec:
      command:
      - /bin/sh
      - -c
      - /health/healthcheck.sh
     failureThreshod: 3
     initialDelaySeconds: 45
     PeriodSeconds: 5
     successThreshold: 1
     timeoutSeconds: 10

 

在容器中运行命令,返回0代表正常,非0表示失败,则触发重启

b. httpGeet

如:http-get http://:8080/actuator/health delay=120s timeout=5s period=10s #success=1

通过发起换一个http get request,根据返回状态码,来判断成功还是失败

c. tcpSocket

顾名思义,对指定tcp 端口进行探测。

 

posted @ 2021-04-04 22:25  一个门外汉  阅读(137)  评论(0编辑  收藏  举报