Use case
"I want to deploy elasticsearch + kibana, by using elastic official helm charts. I want to create a helm chart called data-viz with these charts as dependency."
Running helm install data-viz --set cluster=toto
must create an elasticsearch cluster "toto", and a kibana configured with elasticsearchHosts
= toto.
Problem
I see here https://github.com/helm/helm/blob/master/docs/chart_template_guide/subcharts_and_globals.md it's possible to configure sub-chart from main-chart values.yml
. But I would like templatize sub-chart values.yml from main-chart values.yaml, is it possible?
I was thinking to something simple as:
.
├── Chart.yaml
├── charts
│ ├── elasticsearch
│ │ ├── Chart.yaml
│ │ └── templates
│ │ └── values.yaml
│ ├── elasticsearch-7.4.0.tgz
│ └── kibana-7.4.0.tgz
├── requirements.lock
├── requirements.yaml
└── values.yaml
Hack solution
A small Python script that creates the values.yaml
file from sub-chart/values-template.yaml
+ data.
I had almost the same problem and found no appropriate solution. I only found this issue. They suggested using Lua in an upcoming helm release. But Lua is still not available with helm 3.0.
Therefore, I decided to implement a tool which is mostly helm compatible and is able to configure sub charts by a sandboxed Pythonic language.
For your problem it should be sufficient to put a Chart.star
file in the root folder (parallel to Chart.yaml
) with the following content
def init(self, cluster="clustername"):
self.elastic = chart("charts/elasticsearch-7.4.0.tgz")
self.kibana = chart("charts/kibana-7.4.0.tgz")
self.elastic.cluster = cluster # Please use the right name here (from elastic../values.yaml
self.kibana.elasticsearchHosts = cluster
and run
shalm apply data-viz --set cluster=toto