See Helm documentation for full list of available functions
name: {{ .Values.storageClassName }}
name: {{ .Values.storageClassName | quote }}
name: {{ .Values.storageClassName | default "default value" }}
name: {{ .Values.storageClassName | required ".storageClassName must be set" }}
name: {{ .Values.storageClassName | trim }}
name: {{ printf "%s-%d" .Values.storageClassName .Values.storageClassVersion }}
name: {{ .Values.storageClassName | replace "{placeholder}" "example" }}
{{ $fullName := printf "%s %s" .Values.firstName .Values.lastName }}
name: {{ .Values.storageClassName | trimAll "/" }}
name: {{ .Values.storageClassName | trimPrefix "/" }}
name: {{ .Values.storageClassName | trimSuffix "/" }}
name: {{ .Values.storageClassName | lower }}
name: {{ .Values.storageClassName | upper }}
See Helm documentation for all options
{{ .Release.Name }}
{{ .Release.Namespace }}
{{ .Chart.Name }}
{{ .Chart.Version }}
{{ .Files.Get config.ini }}
{{ if .Values.enablePersistence }}
# ...
{{ else if .Values.enableFilesystem }}
# ...
{{ else }}
# ...
{{ end }}
# equal, not equal
{{ if eq .Values.environment "production" }}
{{ if ne .Values.environment "production" }}
# and, or
{{ if and (eq .Values.environment "production") (eq .Values.host "minikube") }}
{{ if or (eq .Values.environment "production") (eq .Values.host "minikube") }}
# not (negation)
{{ if not (eq .Values.environment "production") }}
# greater than, less than
{{ if gt (len .Values.items) 3 }}
{{ if gte (len .Values.items) 3 }}
{{ if lt (len .Values.items) 3 }}
{{ if lte (len .Values.items) 3 }}
# strings
{{ if .Values.name | contains "example" }}
{{ if .Values.name | hasPrefix "foobar-" }}
{{ if .Values.name | hasSuffix "-foobar" }}
{{ if .Values.name | regexMatch "^[a-z]+$" }}
# lists
{{ if .Values.items | has "example" }}
# ternary
{{ ternary "returned if true" "returned if false" .Values.someBoolean }}
# simple
volumes:
{{ range .Values.volumeIds }}
- volumeName: {{ . }}
{{ end }}
# with named variable
volumes:
{{ range $volumeId := .Values.volumeIds }}
- volumeName: {{ $volumeId }}
{{ end }}
# with index (array) or key (dict)
volumes:
{{ range $key, $value := .Values.configuration }}
- {{ $key }}: {{ $value }}
{{ end }}
env:
{{ .Values.environmentVariables | toYaml | indent 2 }}
env: {{ .Values.environmentVariables | toYaml | nindent 2 }}
# define templates in _helpers.tpl
{{- define "your-project.image" -}}
{{ printf "%s:%s" .Values.image.name .Values.image.tag | quote }}
{{- end -}}
# use in other files
image: {{ include "your-project.image" . }}
# more specific parameters as the scope
{{- define "your-project.someInclude" -}}
{{ . | replace "{placeholder}" "example" }}
{{- end -}}
# usage
foobar: {{ include "your-project.someInclude" .Values.foobar }}
{{ $previous := lookup "v1" "Secret" .Release.Namespace "some-secret" }}
data:
{{- if $previous }}
foobarPassword: {{ $previous.data.foobarPassword | quote }}
{{- else if .Values.foobarPassword }}
foobarPassword: {{ .Values.foobarPassword | b64enc | quote }}
{{- else }}
foobarPassword: {{ randAlphaNum 40 | b64enc | quote }}
{{- end }}
{{ if eq .Values.storageClassName "foobar1" }}
# ...
{{ else if eq .Values.storageClassName "foobar2" }}
# ...
{{ else }}
{{ fail ".storageClassName is not recognized" }}
{{ end }}
See Helm documentation for notes about formatting
# ISO 8601, format string is provided as a lookalike-string
{{ now | date "2006-01-02T15:04:05" }}
{{ .Values.someData | b64enc }}
{{ .Values.someData | b64dec }}
id: {{ uuidv4 }}
{{ .Values.someData | sha256sum }}
{{ .Values.someData | encryptAES "secret key" }}
{{ .Values.someData | decryptAES "secret key" }}
Source code for this page can be found on GitHub.
FYI! This site uses Fathom Analytics which does not use cookies. Use this link for a $10 discount.