robusta icon indicating copy to clipboard operation
robusta copied to clipboard

Add `nameOverride` and `fullnameOverride` in helm chart

Open kristeey opened this issue 1 year ago • 5 comments

Add possibility to overwrite naming in helm chart adding nameOverride and fullnameOverride helpers.

These are commonly used helpers and helpful in scenarios where the robusta helm chart is used as a subchart. Without the opportunity to override the naming -> the robusta manifest will be enriched with the release name of the parent chart.

kristeey avatar Apr 19 '24 12:04 kristeey

I belive this is already covered by my PR. Look at the helper template codelines: https://github.com/robusta-dev/robusta/blob/e31d6db8a2e3ee9a6ab1f413422411843044c64a/helm/robusta/templates/_helpers.tpl#L17-L21

If fullnameOverride and/or nameOverride isn't specified the robusta.fullname template is just .Release.name

kristeey avatar Apr 26 '24 10:04 kristeey

Maybe I'm reading it wrong.. {{- $name := default .Chart.Name .Values.nameOverride }} - here name will be the Chart name

then {{- if contains $name .Release.Name }} and here we check if the Chart name is in the Release name?

The chart name is probably fixed, and the release name can be anything, isn't it?

arikalon1 avatar Apr 26 '24 11:04 arikalon1

Yes. The .Chart.Name is static and determined by the name value in Chart.yaml. It then checks if the name variable (consisting og the chart name or the nameOverride value (if given)) is a substring of the release name. If it is: robusta.fullname will be the release name. If it is not a substring robusta.fullname will be the release name + name variable. But if nameOverride is empty, robusta.fullname will be the release name + chart name.

This is a common practice for helm charts, some examples are:

It is easy to verify the output with this command

helm install my-release-name ./robusta -f values.yaml --dry-run

playing around with the release name and the fullnameOverride and/or nameOverride values.

kristeey avatar Apr 26 '24 12:04 kristeey

Well, There is however some cases where this will break as you point out. E.g. if someone has a completely different release name e.g. some-release which will result in robusta.fullname being some-release-robusta...

A possibility is to remove the nameOverride value, as fullnameOverride will be sufficient in my usecase.

kristeey avatar Apr 26 '24 12:04 kristeey

can you please simplify the logic, to something like:

{{- define "robusta.fullname" -}}
{{- if .Values.fullnameOverride }}
.... all the logic for the override
{{- else }}
{{- .Release.Name | trunc 63 }}
{{- end }}
{{- end }}

So if someone doesn't specify the fullnameOverride nothing changes

arikalon1 avatar Apr 26 '24 13:04 arikalon1

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 29 '24 06:04 CLAassistant