kubernetes - 如何防止在初始化完成之前将Pod添加到kube服务

标签 kubernetes

有时,某个Pod应该花一些时间进行“热身”(例如,将某些数据加载到缓存中)。那时它不应该被暴露。

如何防止Pod添加到kube-service unitl初始化完成?

最佳答案

您应该使用健康检查。更具体地说,在Kubernetes中,您需要一个ReadinessProbe

ReadinessProbe: indicates whether the container is ready to service requests. If the ReadinessProbe fails, the endpoints controller will remove the pod’s IP address from the endpoints of all services that match the pod. The default state of Readiness before the initial delay is Failure. The state of Readiness for a container when no probe is provided is assumed to be Success.



另外,与LivenessProbe的区别:

If you’d like to start sending traffic to a pod only when a probe succeeds, specify a ReadinessProbe. In this case, the ReadinessProbe may be the same as the LivenessProbe, but the existence of the ReadinessProbe in the spec means that the pod will start without receiving any traffic and only start receiving traffic once the probe starts succeeding.



http://kubernetes.io/docs/user-guide/pod-states/

关于kubernetes - 如何防止在初始化完成之前将Pod添加到kube服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40499218/

相关文章:

docker - 如何在 mini(Kubernetes) 环境中运行 composer install

kubernetes - 如何将kubernetes中的容器提升到另一个命名空间(environment/DTAP)?

postgresql - 无法从外部登录到 Kubernetes 集群内部的 Postgres

kubernetes - 亲和性 - 在 Kubernetes 中每个节点仅运行 x 个 Pod?

docker - 将用户添加到现有的Kubernetes集群

Angular 7 - Kubernetes 服务中的 Rest API 消耗(未公开)

kubernetes - 以编程方式查找过量使用的Kubernetes节点

kubernetes - Grafana Helm 通知配置

kubernetes - 通过队列动态创建带有 kubernetes 的 pod

docker - nginx-ingress 显示部署在域路径上的 React 应用程序的 HTTP 错误 404,但适用于子域路径