Depending on a subchart via requirements.yaml results in the template being rendered. I'm aware that I can use aliases to have more than one copy of a subchart, but is there a way to prevent the subchart to be rendered by default and instead included
as a template, along the lines of:
{{- $root := . }}
{{- range $i, $service := .Values.services }}
---
{{ $k8sDeployment := (include "MY_SUBCHART_NAME" (dict "top" $root "deployment" $service)) | fromYaml }}
{{ include "deployment" (dict "top" $root "deployment" $k8sDeployment) }}
---
{{ $k8sService := (include "MY_SUBCHART_NAME2" $service) | fromYaml }}
{{ include "service" (dict "top" $root "service" $k8sService) }}
{{- end -}}
CodePudding user response:
No, there's no way to do this. Helm dependencies (both in Helm 2 and Helm 3) work only as things that are installed in the cluster under the same Helm release name. Without using something like a post-renderer to manipulate the produced YAML, there's no way to include only part of a dependency chart or to re-include its Kubernetes objects with different parameters.
One could imagine the subchart being specifically designed to be used this way. The subchart would have to provide the templates you're trying to call, and its templates/*.yaml
file would call those templates with standard values inside an if
block, and then your parent chart could depend on the subchart with a value that disabled its normal output. Most charts aren't built this way, though.