• Helm templates: Using fullname inside a range block

    2 min read

    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

    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

    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

    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...
  • Helm template: Array to a comma separated string

    2 min read

    While writing Helm charts we might need to transform some values that are going to be defined as an array as a value into a comma separated string

    12/11/2021

    Read more...

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