序列化 pods/ helm 图表的部署

Serialising the deployment of pods/ helm charts

我有多个 helm chart,每个创建一个部署(通常每个创建一个 pod)。

要求是序列化 pods 的部署,即在部署第二个 pod 之前,第一个 pod 需要处于 运行 状态。 (因为第二个 pod 从第一个 pod 读取值)。第三个 pod 应该只在第二个 pod 启动并且 运行 或完成时出现。

我尝试为此使用 Umbrella helm 挂钩,但挂钩是在图表对象级别而不是图表集合上评估的。

我正在寻找一个 init 容器,它会在 运行 第二个 pod 之前定期检查第一个 pod 的就绪探测(不确定是否可以完成)?不确定 -- 有想法...

初始化容器

如果您不介意让之前的服务 运行 在下一个服务 运行 之前完成,您可以利用 Init Containers 功能:https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

They run to completion before any app Containers start, whereas app Containers run in parallel, so Init Containers provide an easy way to block or delay the startup of app Containers until some set of preconditions are met.

行为

During the startup of a Pod, the Init Containers are started in order, after the network and volumes are initialized. Each Container must exit successfully before the next is started. If a Container fails to start due to the runtime or exits with failure, it is retried according to the Pod restartPolicy. However, if the Pod restartPolicy is set to Always, the Init Containers use RestartPolicy OnFailure.

A Pod cannot be Ready until all Init Containers have succeeded. The ports on an Init Container are not aggregated under a service. A Pod that is initializing is in the Pending state but should have a condition Initializing set to true.

If the Pod is restarted, all Init Containers must execute again.

https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#detailed-behavior

注意事项

在决定使用此功能之前,请查看文档中的差异和限制。

Differences from regular Containers

Init Containers support all the fields and features of app Containers, including resource limits, volumes, and security settings. However, the resource requests and limits for an Init Container are handled slightly differently,