kubernetes - statefulset 的就绪探测,而不是单个 pod/容器

标签 kubernetes google-kubernetes-engine kubernetes-statefulset

我一直在阅读 liveness and readiness probes in kubernetes我想用它们来检查集群是否活跃。

问题是如何为整个 statefulset 配置就绪探测器,而不是单个 pod/容器。

可以使用简单的 HTTP 检查来确定就绪情况,但我遇到的问题是 readinessCheck 似乎适用于容器/pod,而不适用于集合本身。

对于我正在使用的软件,HTTP 端点在集群形成之前不会出现;这意味着每个单独的 pod 都将无法通过 readinessCheck,直到所有三个 pod 都启动并找到彼此。

我现在在 Kubernetes 中看到的行为是创建了 3 个副本中的第一个,并且 Kubernetes 甚至不会尝试创建副本 2 和 3,直到第一个通过 readinessCheck,但这种情况从未发生过,因为所有三个副本都有为它有机会通过它做好准备。

最佳答案

您需要将 StatefulSet.spec.podManagementPolicyOrderedReady 更改为 Parallel 策略。

这样 K8S 将并行启动所有 pod,而不会等待探测。

来自 documentation

podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is OrderedReady, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is Parallel which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.

关于kubernetes - statefulset 的就绪探测,而不是单个 pod/容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50971333/

相关文章:

docker - 如何让容器在 Kubernetes 上运行?

python - Ansible K8s 模块 : Failed to import the required Python library (openshift) on Python/usr/bin/python3

go - 如何在 GKE 中使用 HTTPS 部署 Echo 应用程序?

kubernetes - 2 个具有共享 Redis 依赖关系的 Helm Charts

kubernetes - Google调试:如何调试可执行jar中的库-错误:在可执行文件中找不到文件

Kubernetes StatefulSet - 在配置的其他地方获取 spec.replicas 元数据和引用

Kubernetes:具有本地配置程序和 StatefulSet 类型的 StorageClass

kubernetes - 将POD_HOST + random_string导出为Pod中的环境变量

docker - Kubernetes中 secret 的用途是什么,它的目的是什么?

java - Spring Boot无法连接到部署在另一个kubernetes pod上的postgres数据库