helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

Improve namespacing of templates to prevent conflicts between charts

Open bluepichu opened this issue 7 months ago • 0 comments

Currently, some templates are defined in multiple charts under the same name, but with different implementations. Sometimes these implementations are completely incompatible, such as the neo4j.nodeSelector template being incompatible between the neo4j and neo4j-admin charts.

This is a problem because it is often desirable to maintain these charts together as subcharts of a common parent chart. For example, I'm trying to use this Chart.yaml alongside an appropriate values.yaml to manage a database and its associated backup infrastructure in a single chart as part of a larger application:

apiVersion: v3
appVersion: "0.1.0"
description:
name: my-neo4j-app
version: 0.1.0
dependencies:
  - name: neo4j
    repository: https://helm.neo4j.com/neo4j
    version: 5.20.0
  - name: neo4j-admin
    alias: neo4j-backup
    repository: https://helm.neo4j.com/neo4j
    version: 5.20.0
    condition: backup.enabled

This currently errors out due to the conflicting definitions of some templates.

The solution used here is to namespace all of the templates by the specific chart that they are a part of rather than by simply neo4j. For example, the fullname template in neo4j-admin is renamed from neo4j.fullname to neo4jAdmin.fullname to prevent a potential conflict with the main neo4j chart. The actual method of doing this was just a find-replace of (?<=define |template )"neo4j.([^"]*)" for "<chartname>.$1" within each chart.

A note on testing: I only tested this so far as making sure it worked for my neo4j + neo4j-admin setup. I couldn't figure out how to run the tests locally, but I'm assuming they should run on this PR and catch any cases I might have missed.

bluepichu avatar Jul 18 '24 19:07 bluepichu