Enabling code reuse with named templates and library charts
When creating template files, there may be boilerplate or repetitive blocks of YAML among the different Kubernetes resources in a chart.
For example, you may strive to use a consistent set of labels for each resource, as illustrated here:
labels: "app.kubernetes.io/instance": {{ .Release.Name }} "app.kubernetes.io/managed-by": {{ .Release.Service }} "helm.sh/chart": {{ .Chart.Name }}-{{ .Chart.Version }} "app.kubernetes.io/version": {{ .Chart.AppVersion }}
The preceding labels could be copy-pasted manually throughout your templates, but this would be cumbersome, especially if you wanted to make updates to these labels in the future. To help reduce the amount of boilerplate code and to enable reuse, Helm provides a construct called named templates.
Named templates, as with regular Kubernetes templates, are defined under the templates...