I have a simple structure of charts:
chart1
-templates
-deployment.yaml
-configmap.yaml
-service.yaml
chart2
-templates
-deployment.yaml
-configmap.yaml
-service.yaml
redis
-templates
-deployment.yaml
-service.yaml
Now chart2 is depending on redis and needs it to run. and chart1 depend on both redis and chart2. (basically they are both services that uses redis to store info and chart1 sends requests to chart2).
When I install chart2 it's all fine but if I install chart1 it will try to install both its redis and the redis that is subchart of chart2 (which is the same redis).
So to prevent this collision I use a tag to prevent the second redis from installing, so by installing chart1 I also install chart2 and one instance of redis.
The problem is, chart2 needs to know the name of the redis service (assuming it can be dynamically created with the installation) and I don't have access to it from chart2.
I use the template "redis.fullname" to name all the resources of redis. chart1 has access to this template because redis is its subchart on installation (using .Subcharts.redis), but its not the subchart of chart2 in this instance, so chart2 doesn't have access to "redis.fullname" and therefore cant use the correct service name in its configmap.
I hope I made sense when describing the problem. is there any solution to this?
In case you have control over the code in your charts, you can use global values: https://helm.sh/docs/chart_template_guide/subcharts_and_globals/