Deploying multiple Helm charts despite duplicated objects

10/9/2021

I have 2 helm child charts and 1 umbrella chart which depends on both childs. Unfortunately the both child charts contain duplicated k8s objects (so they also share the same name).

So on doing helm install release1 umbrella I get Error: configmaps "x-1" already exists.

Hint: We are the authors of the "child" charts (so we can change them) but we can not avoid name collisions.

Is it possible to do helm install despite some k8s objects are duplicated ? Could we adapt the "child" charts to make it possible (like "consider this object only if not already defined")

I know it is possible doing it with plain kubectl since it will merge the duplicates without errors.

-- mr.wolle
kubernetes
kubernetes-helm

1 Answer

10/9/2021

A typical Helm convention is to name objects after both the release name and the chart name. In a dependency-chart situation, each of the charts will have its own chart name, but all of the charts will share the same release name.

metadata:
  name: {{ .Release.Name }}-{{ .Chart.Name }}-x-1

If you create a chart with helm create, it will include a "chartname.fullname" helper in _helpers.tpl that helps to construct this name in a standard way.

This approach will get you two separate, non-conflicting ConfigMaps, but they might have duplicated content.

If you want to have only one copy of the ConfigMap, you can move it into its own chart, and have the two "child" charts depend on that. If the umbrella chart depends on A and B, and A and B both depend on some common dependency C, Helm will only install that dependency once. The service charts A and B will still know the name of the ConfigMap, since they know the release name (the same as the current .Release.Name) and the chart name (the name of the common dependency chart).

configMapRef:
  name: {{ .Release.Name }}-common-x-1
-- David Maze
Source: StackOverflow