Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm adds release name to dependent charts

I have few dependencies like this

dependencies:
- name: some-chart
  version: "1.2.3"
  repository: "file://../some-chart"

And I install my chart like so

helm install my-chart .

However, it adds dependent charts my release name. so for example server-0 pod deploys like this

my-chart-some-chart-server-0

If I only install the dependent chart on its own, for example helm install some-chart ../some-chart it deploys 'server-0' like this

some-chart-server-0

Is there a way to deploy dependent charts without adding release name as its intended?

like image 852
Can Uysal Avatar asked Oct 23 '25 14:10

Can Uysal


2 Answers

Some time has passed but this may be important information for other users -

As David has explained this can not be changed by helm and comes from the templates.

If you can find the following in the templates

{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}

then you can use the fullnameOverride for your needs.

You can override the values of the dependency by adding in the parent's (my-chart) values.yaml file the following:

some-chart:
 fullnameOverride: some-chart

As a result, the parent's chart name (my-chart) will be dropped from the names of the resources and you will see your server-0 pod as some-chart-server-0 instead of as my-chart-some-chart-server-0.

like image 93
Sonia Avatar answered Oct 26 '25 19:10

Sonia


This naming convention is part of the templates. Helm doesn't add it itself, and you can't change it without changing the templates (or doing complex post-processing).

If you run helm create, it creates a lot of infrastructure for you. Things like the Deployment are generally named

name: {{ include "<CHARTNAME>.fullname" . }}

That template, in turn, is also part of the generated _helpers.tpl file (trimmed slightly)

{{- define "<CHARTNAME>.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

So if you helm install some-chart ../some-chart, the release name (the first some-chart argument) matches the chart name, and you get the "short" form of just the release name; but if you helm install other-chart ../some-chart, you'll get the release-name-chart-name-suffix format.

This has nothing to do with it being a dependency, only the name you're using to install the release. Compare:

helm install some-chart ../some-chart  # using its "normal" name
helm install foo ../some-chart         # using some other name
helm install my-chart .                # "normal" name of parent, not dependency
helm install some-chart .              # "normal" name of dependency, not parent

This last case should be interesting: if your parent chart uses the same convention, you will actually see names like some-chart-my-chart-deployment, but the some-chart dependency will see the release and chart names match and so within that dependency you'll just see some-chart-foo.

like image 31
David Maze Avatar answered Oct 26 '25 19:10

David Maze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!