k8s-livenessProbe与ReadinessProbe [英] k8s - livenessProbe vs readinessProbe

查看:167
本文介绍了k8s-livenessProbe与ReadinessProbe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑一个通过http端点/health在端口80上进行运行状况检查的吊舱,该吊舱实际上需要花费60秒钟的时间才能准备就绪&为交通服务.

Consider a pod which has a healthcheck setup via a http endpoint /health at port 80 and it takes almost 60 seconds to be actually ready & serve the traffic.

readinessProbe:
  httpGet:
    path: /health
    port: 80
  initialDelaySeconds: 60
livenessProbe:
  httpGet:
    path: /health
    port: 80

问题:

  • 我的上述配置是否符合给定的要求?
  • 活度探测器只有在吊舱准备就绪后才能开始工作吗?换句话说,我认为一旦POD准备就绪,就绪探测工作就完成了.之后,livenessProbe会进行健康检查.在这种情况下,我可以忽略livenessProbe的initialDelaySeconds.如果它们是独立的,那么在吊舱本身未准备好时检查livenessProbe的意义是什么! ?
  • 检查此文档.
  • 是什么意思
  • Is my above config correct for the given requirement?
  • Does liveness probe start working only after the pod becomes ready ? In other words, I assume readiness probe job is complete once the POD is ready. After that livenessProbe takes care of health check. In this case, I can ignore the initialDelaySeconds for livenessProbe. If they are independent, what is the point of doing livenessProbe check when the pod itself is not ready! ?
  • Check this documentation. What do they mean by

如果您希望自己的集装箱能够自行拆除 维护,您可以指定一个用于检查端点的就绪探针 专门针对准备情况而不同于活动性探针.

If you want your Container to be able to take itself down for maintenance, you can specify a readiness probe that checks an endpoint specific to readiness that is different from the liveness probe.

我以为,仅当livenessProbe失败时,运行中的吊舱才会自行倒下.不是readinessProbe.医生说另一种方式.

I was assuming, the running pod will take itself down only if the livenessProbe fails. not the readinessProbe. The doc says other way.

澄清!

推荐答案

活动探针将检查容器是否已启动并处于活动状态.如果不是这种情况,kubernetes最终将重新启动容器.

The liveness probes are to check if the container is started and alive. If this isn’t the case, kubernetes will eventually restart the container.

准备情况探测还会依次检查依赖关系,例如数据库连接或您的容器要完成其工作所依赖的其他服务.作为开发人员,您必须在这里花更多的时间在实施上,而不仅仅是活动性探针.您必须公开一个端点,该端点在查询时还要检查提到的依赖项.

The readiness probes in turn also check dependencies like database connections or other services your container is depending on to fulfill it’s work. As a developer you have to invest here more time into the implementation than just for the liveness probes. You have to expose an endpoint which is also checking the mentioned dependencies when queried.

您当前的配置使用运行状况探针,通常由活动性探针使用.它可能不会检查您的服务是否真的准备好吸引流量.

Your current configuration uses a health endpoint which are usually used by liveness probes. It probably doesn’t check if your services is really ready to take traffic.

Kubernetes依赖于准备情况探针.在滚动更新期间,它将保持旧容器的正常运行,直到新服务声明已准备好接受流量为止.因此,就绪探针必须正确实施.

Kubernetes relies on the readiness probes. During a rolling update, it will keep the old container up and running until the new service declares that it is ready to take traffic. Therefore the readiness probes have to be implemented correctly.

这篇关于k8s-livenessProbe与ReadinessProbe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆