Templating language and helm

9/26/2019

I am new to kubernetes and helm. I started using helm and I have the follwoing snippet:

{{- $image := printf "%s/%s:%s" $.Values.global.repository $.Values.global.images.xxx.image $.Values.global.images.xxx.tag -}}
apiVersion: v1
kind: Pod
metadata:
  name: xxxx-test-ready
  labels:
    app: xxxxx-test
    app.kubernetes.io/name: xxxxx-test
    helm.sh/chart: authsvc
    release: {{ $.Release.Name }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}

My issue is here:

  {{- $image := printf "%s/%s:%s" $.Values.global.repository $.Values.global.images.xxx.image $.Values.global.images.xxx.tag -}}

I think I understand what it does : basically it creates the image specification and add it to a var called image for later use case. however I do not feel comfortable with this templating language and I am not even sure if it is erlang or golang. What is the best starting point to get confident with this templating language? Should I learn golang?

-- Learner
kubernetes
kubernetes-helm

1 Answer

9/26/2019

The best starting point is to read the official documentation: The Chart Template Developer’s Guide, which provides an introduction to Helm’s chart templates, with emphasis on the template language.

While we talk about “Helm template language” as if it is Helm-specific, it is actually a combination of the Go template language, some extra functions, and a variety of wrappers to expose certain objects to the templates. Many resources on Go templates may be helpful as you learn about templating.

Helm has over 60 available functions. Some of them are defined by the Go template language itself. Most of the others are part of the Sprig template library.

Dig into the above Sprig and Go Template documentation to enhance your knowledge about chart templates.

-- Eduardo Baitello
Source: StackOverflow