I'm trying to figure out how to share data between two charts in helm.
I've set up a chart with a sole YAML for a configmap in one chart. Let's call the chart cm1. It defines it's name like so:
name: {{ .Release.Name }}-maps
Then I set up two charts that deploy containers that would want to access the data in the configmap in c1. Let's call them c1 and c2. c1 has a requirements.yaml that references the chart for cm1, and likewise for c2. Now I have a parent chart that tries to bring it all together, let's call it p1. p1 defines c1 and c2 in requirements.yaml. The I helm install --name k1 p1
and I get an error:
Error: release k1 failed: configmaps "k1-maps" already exists.
I thought that when helm builds its dependency tree that it would see that the k1-maps was already defined when chart cm1 was first loaded.
What's the best practice to share a configmap between two charts?
You haven't given a ton of information about the contents of your charts, but it sounds like both c1 and c2 are defining and attempting to install the configmap. Helm doesn't really know anything special about the dependencies, it just knows to also install them. It will happily attempt (and fail) to install the chart a second time if told to.
The configmap should be created and installed only as part of the parent chart. C1 and C2 should be able to reference it by name even though it isn't defined in either of them.