Custom helm chart requires another stable/chart

9/19/2019

I've created a chart which requires a helm chart from stable/charts, lets say mongodb. Although you can define a requirements.yaml file I was wondering if it is possible to define a chart in here?

Furthermore, to make things easier (not) I need to replace some values for the mongodb chart as well. Not sure if I'm pushing the limits here to much :) It looks like a subchart relation, so it sounds possible.

The alternative, which I'm using now is to first install the stable/chart and then my custom chart. But it would be an improvement if I could reduce this to one helm command just by adding this dependency to my custom chart

Update:

I will update this post with my findings and hopefully this will eventually lead to the solution :) The requirements.yaml so far:

dependencies:
  - name: "mongodb"
    version: "4.x.x"
    repository: "@stable"
    import-values:
      - child: default.data
        parent: myimports

Not sure yet how I can use import-values to customize mongodb, but for now I'm stuck on the following error

Error: found in requirements.yaml, but missing in charts/ directory: mongodb

Also, because I'm using stable I'm not sure what to do with the version field

Useful links: link, link

-- Jeanluca Scaljeri
kubernetes
kubernetes-helm

3 Answers

4/10/2020

Handling 3rd party charts in your own repo might be the trivial solution since you need one helm command to run it, but it makes maintenance much more cumbersome.

I would go with defining the helm dependencies and then running a small script to download them just like any other package-management system would do, you can do it as following:

Defining

requirements.yaml

dependencies:
- name: "mongodb"
 version: "7.8.10" <--- Pay attention this refers to the chart's version and not the app version [see link 1]
    repository: "@stable"

1. https://github.com/helm/charts/blob/master/stable/mongodb/Chart.yaml#L3

Installing

run shell script that creates the charts folder and get the charts in the requirements.yaml

install.sh

helm dependencies list
helm dependencies update
helm install --name my-chart . 

Passing values to sub-charts

in case you want to change the values of the sub-chart you need to follow the exact same path of the chart's value path (in this example ingress.enabled) and add the top level chart name.

Pay attention! this have to be an exact match to the chart name mentioned in the requirements.yaml!

There are two ways to set those values:

either with the command line: helm install --name my-chart . --set mongodb.ingress.enabled=true or inside your own values.yaml

mongodb:
  ingress:
    enabled: "true"
-- Totem
Source: StackOverflow

9/23/2019

since helm 2.2.0, you can store the mongodb chart at the same directory and in your requirements.yaml file refer to it as:

dependencies:

- name: mongodb
  version: "<the_mongo_chart_version>"
  repository: "file://../mongodb"

thats way you can play with the values and deploy the whole thing with 1 helm command.

for more information refer to

https://github.com/helm/helm/blob/master/docs/helm/helm_dependency.md

-- Efrat Levitan
Source: StackOverflow

10/11/2019

Unfortunately this not enough to add dependency charts into your requirements.yaml file.

Also, charts himself should be physically in charts directory. This is a helm limitation.

If you agree to manage a third party chart in your repo (should be pretty easy) then you be able to install all by one helm command and change subchart values as mentioned here.

I have an example elasticsearch and kibana installation as one chart: In my test repo. Please review. I hope this example helps to solve your problem.

-- ozlevka
Source: StackOverflow