• Import files into objects using helm

    2 min read

    helm ConfigMap Secret file

    When writing helm charts being able to specify the files to use for ConfigMap or a Secret objects is way more convenient than having the object already rendered. Using .Files.Glob we can tell help to import a set of files into the object

    08/07/2022

    Read more...
  • Helm templates: Using fullname inside a range block

    2 min read

    helm template fullname range

    If we try to use the template fullname function inside a range block as follows:

    {{ range .Values.secrets }}
    ---
    apiVersion: 'kubernetes-client.io/v1'
    kind: ExternalSecret
    metadata:
      name: "{{ template "pet2cattle.fullname" . }}-{{ . | replace "_" "-" }}"
    (...)
    {{ end }}
    

    We will get a can't evaluate field Values in type string like follows:

    Error: template: pet2cattle/templates/_helpers.tpl:14:14: executing "pet2cattle.fullname" at <.Values.fullnameOverride>: can't evaluate field Values in type string
    

    29/12/2021

    Read more...
  • Helm: Usage of definitions across files

    1 min read

    helm template definition

    Sometimes writting helm charts can be very challenging due to the weird errors we might get:

    <sha256sum>: wrong type for value; expected string; got chartutil.Values
    

    26/11/2021

    Read more...
  • How to retrieve one of the elements of an array on a Helm template

    2 min read

    helm template array index element

    While working on Helm charts we might be interested on using a particular element of an array (most likely the first). To achieve this we won't be able to use the regular square brackets approach, instead we will have to use the index function

    25/11/2021

    Read more...
  • 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