TIL: Library Helm charts share templates, not workloads
Every chart I work on ends up with the same handful of helper templates: standard labels, a fullname helper, the same resource-limit boilerplate. I used to copy them from chart to chart. Library charts are Helm’s answer to that.
A library chart is a chart with type: library in its Chart.yaml:
apiVersion: v2
name: common
version: 0.1.0
type: library
Instead of manifests, it only ships named templates โ the define blocks you’d normally keep in _helpers.tpl:
{{- define "common.labels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
An application chart pulls it in as a regular dependency:
# the app chart's Chart.yaml
dependencies:
- name: common
version: 0.1.0
repository: file://../common
and then calls the helpers like its own:
metadata:
labels:
{{- include "common.labels" . | nindent 4 }}
The library chart itself deploys nothing. It has no rendered manifests of its own, and Helm refuses to install it standalone โ it exists purely to be depended on.