简体   繁体   English

舵-取决于其他子图的子图

[英]Helm - Subchart dependent on other subchart

I have a Parent chart with two sub-charts subchart1 and postgres and there is a pre-install job in subchart1 which creates necessary tables/schema's for subchart1 service, where the job is in turn dependent on postgres sub-chart to be installed first, so when I install the parent chart with pre-install job hook, it fails because the postgres sub-chart is not installed yet. 我有两个子图父图表subchart1postgres ,有一个pre-install在工作subchart1它创建必要的表/架构对subchart1服务,那里的工作又依赖于postgres子图先安装,因此,当我使用pre-install作业挂钩安装父图表时,它会失败,因为尚未安装postgres子图表。

To overcome this problem I changed job from pre-install to post-install or install , used initContainer to wait until postgres sub-chart is installed before starting the job, 为了解决这个问题,我将作业从pre-install更改pre-install post-install or install ,使用initContainer等到开始安装postgres子图后再开始作业,

the issue now I am facing is how to make sure the job is run before installing the subchart1 when doing an subchart1 upgrade 我现在面临的问题是如何确保作业在安装之前运行subchart1做的时候subchart1升级

One way I can think of is have a initContainer in the subchart1 to wait until the job is finished, how to notify subchart1 that the job is finished 我能想到的一个方法是有initContainersubchart1等到工作结束时,如何通知subchart1作业完成

Rather than using helm concepts, you can use k8s concepts to solve this problem. 您可以使用k8s概念来解决此问题,而不是使用掌舵概念。 You can add a k8s job to your subchart1 which runs to completion and creates the needed tables. 您可以将K8S作业添加到您的subchart1它运行到完成,并创建所需的表。 The initContainer in other pods can be used to wait for the k8s job to complete. initContainer在其他吊舱可以用来等待K8S作业完成。 The k8s job can fail if the needed dependency postgres is not up. 如果所需的依赖项postgres没有启动,则k8s作业可能会失败。 On failure, k8s will make sure to re-run the job. 如果出现故障,k8s将确保重新运行该作业。 The job is ran to completion. 该工作已完成。

Rather than using init-containers to wait, you can also choose to use liveness and readiness-probe. 除了使用init容器等待之外,您还可以选择使用活动性和就绪性探针。 The readiness probe is generally implemented using /ready API. 准备情况探测器通常使用/ ready API来实现。 If the readiness-probe fails, no tarffic is sent to the POD. 如果准备就绪探针失败,则不会将目标数据发送到POD。 If liveness-probe fails, the POD is restarted. 如果活动探针失败,则重新启动POD。 See k8s docs on configuring liveness and readiness probe 请参阅有关配置活动性和就绪性探针的k8s文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM