• Helm: Include definitions on templates

    2 min read

    helm template include define

    Sometimes we might need to add the same content twice on the same Helm chart. A tipical example would be the labels on the Pods that need to match the selectos on the Service. For this when you create a helm chart there are already some default definitions, for example:

    {{/* Common labels */}} {{- define "pet2cattle.labels" -}} helm.sh/chart: {{ include "pet2cattle.chart" . }} {{ include "pet2cattle.selectorLabels" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* Selector labels */}} {{- define "pet2cattle.selectorLabels" -}} app.kubernetes.io/name: {{ include "pet2cattle.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} 

    16/11/2021

    Read more...

From pet to cattle
Treat your kubernetes clusters like cattle, not pets