Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>How can I accomplish this? So far my ChartA's requirements.yaml looks like:</p>
  
  <pre><code>dependencies:
    - name: chartb
      version: "0.1.0"
      repository: "https://my.repository.url/charts/"
  </code></pre>
  
  <p>If I go and run <code>helm install charta --name instance-a</code> it finds chartb just fine and installs it, but if I run the install a second time with <code>helm install charta --name instance-b</code> it fails with <code>Error: release instance-b failed: services "chartb" already exists</code></p>
  
  <p>In other words, instead of recognizing the chartb service was already installed and working, it tried to install it again and failed.</p>
  
  <p><strong>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)?</strong></p>
  
Comments: CC BY-SA 4.0
Comments: 2020-04-26T14:28:28.570Z
Comments: Wouldn't a line such as `chartb: {enabled: false}` be an option in the values.yaml of charta for the second installation?
Comments: LLlAMnYP
Comments: CC BY-SA 4.0
Comments: 2020-04-27T17:58:47.670Z
Comments: @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.
Comments: stix
Comments: CC BY-SA 4.0
Comments: 2020-05-08T04:54:00.543Z
Comments: @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.
Comments: Saikat Chakrabortty
Comments: CC BY-SA 4.0
Comments: 2020-05-10T02:54:45.643Z
Comments: @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.
Comments: stix
Comments: CC BY-SA 4.0
Comments: 2020-05-10T06:35:42.660Z
Comments: @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.
Comments: Saikat Chakrabortty
Tags: <kubernetes><helm><dependency-management>
Title: How can I ensure Helm doesn't install a dependency twice?
UserDisplayName: stix
ThreadText: # How can I ensure Helm doesn't install a dependency twice?
  
  (Asked by: username_0 on 2020-04-16)
  
  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:
  
  ```
  dependencies:
    - name: chartb
      version: "0.1.0"
      repository: "https://my.repository.url/charts/"
  
  ```
  
  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)?**
  
  **Tags:** kubernetes, helm, dependency-management
  
  > **Comments:**
  > **username_1**: Wouldn't a line such as `chartb: {enabled: false}` be an option in the values.yaml of charta for the second installation?  
  > **username_0**: @username_1 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.  
  > **username_2**: @username_0 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.  
  > **username_0**: @username_2 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.  
  > **username_2**: @username_0 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.  
  
  ---
  
  ## 0 answers
  
  