How can I ensure Helm doesnt install a dependency twice?

HOW TO -️ October 18, 2021

If I have a chart, say ChartA, that has a dependency on ChartB, I want to only install ChartB if it hasn't been installed already.

Why? Let's say I run 2 copies of ChartA, and they both need a special server in ChartB, but that server is meant to be a singleton between the two instances of ChartA.

How can I accomplish this? So far my ChartA's requirements.yaml looks like:

ERROR Rendering Code Block

If I go and run helm install charta --name instance-a it finds chartb just fine and installs it, but if I run the install a second time with helm install charta --name instance-b it fails with Error: release instance-b failed: services "chartb" already exists

In other words, instead of recognizing the chartb service was already installed and working, it tried to install it again and failed.

How can I ensure that Helm only installs the chartb dependency if it isn't already installed and running (i.e. from a previous instance being started up of charta)?

Answer

Wouldn't a line such as chartb: {enabled: false} be an option in the values.yaml of charta for the second installation? @LLlAMnYP That would require knowing the dependency has already been installed, which I may not know a-priori. It would also require modifying the helm chart when installing chartb. @stix so, usually if there is a dependency cannot avoid it, without that application might not work, but in case the same dependency for multiple charts, I usually override the dependency chart name, which lets me install the dependency in a different name. lots of charts provide this option:nameOverride if it's your custom you have to work on that chart to add this. @SaikatChakrabortty The point is that having it as a dependency breaks the 2nd copy of ChartA because it can't detect that the dependency chartB is already installed. @stix True. as of now, I don't see any option to install the chart only if not exist. the only thing I can think of is, you install the dependency with some other name. if you only looking for the option that let you install only if not exist, use the same otherwise. you have to make your own service for the same.

Initializing...