Closed kivagant-ba closed 5 years ago
I also found that .Values.fullnameOverride
also can be overridden, so actually the syntax may look like this:
{{- $_ := set .Values "fullnameOverride" "my-chart-app-my-stuff" -}}
{{- template "common.deployment" (list . "my.deployment") -}}
{{- define "my.deployment" -}}
## Define overrides for your Deployment resource here, e.g.
spec:
replicas: {{ index .Values "replicas" .Values.fullnameOverride }}
{{- end -}}
Works fine for me. Maybe the trick can be added to README of https://github.com/helm/charts/tree/master/incubator/common but it isn't so critical.
Originally you suggest the following syntax to extend default names for different resources:
But this is inconvenient. When you need to refer to different configuration values for different resources, you have to use something like in the DataDog's example:
As you see, the code can't be reused in templates. But actually there's a trick that may help to make it better. Let's change `common.fullname' a little bit:
Now it checks if
.appName
is set in global scope. And now we can set the name differently in different deployments/services/etc:And in the same time in
values.yaml
we can set the structure:And use it in the same deployment using the
.appName
:So the key difference is that
.Values.fullnameOverride
can be used for the entire chart but.appName
can be set for a specific resource individually which makes templates more clear, reusable and flexible.P.S.: I know about https://github.com/helm/charts/tree/master/incubator/common but I guess it's better to discuss the chart here than in that repo with tons of issues.