Helm Templates: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 39: Line 39:
=Template Objects=
=Template Objects=


=Built-in Objects=
==Built-in Objects==


{{External|[https://helm.sh/docs/chart_template_guide/#built-in-objects Built-in Objects]}}
{{External|[https://helm.sh/docs/chart_template_guide/#built-in-objects Built-in Objects]}}


==Chart==
===Chart===
Exposes all contents of [[Helm Chart Chart.yaml|Chart.yaml]]. An existing field is available as (note leading dot) <tt>.Chart.<''UpperCasedFirstLetterFieldName''></tt>.  
Exposes all contents of [[Helm Chart Chart.yaml|Chart.yaml]]. An existing field is available as (note leading dot) <tt>.Chart.<''UpperCasedFirstLetterFieldName''></tt>.  


Line 50: Line 50:
  &#123;{ .Chart.Version }}
  &#123;{ .Chart.Version }}


==Values==
===Values===
==Release==
===Release===
===Release.Name===
====Release.Name====
Exposes the [[Helm_Concepts#Release_Name|release name]]:
Exposes the [[Helm_Concepts#Release_Name|release name]]:
  &#123;{ .Release.Name }}
  &#123;{ .Release.Name }}
===Release.Revision===
====Release.Revision====
Exposes the [[Helm_Concepts#Release_Revision|release revision]]:
Exposes the [[Helm_Concepts#Release_Revision|release revision]]:
  &#123;{ .Release.Revision }}
  &#123;{ .Release.Revision }}
===Release.Time===
====Release.Time====
Exposes the time of the release:
Exposes the time of the release:
  &#123;{ .Release.Time }}
  &#123;{ .Release.Time }}
===Release.Namespace===
====Release.Namespace====
Exposes the namespace to be released info, if the manifest does not override:
Exposes the namespace to be released info, if the manifest does not override:
  &#123;{ .Release.Namespace }}
  &#123;{ .Release.Namespace }}
===Release.IsUpgrade===
====Release.IsUpgrade====
This is set to true if the current operation is an upgrade or rollback.
This is set to true if the current operation is an upgrade or rollback.
  &#123;{ .Release.IsUpgrade }}
  &#123;{ .Release.IsUpgrade }}
===Release.IsInstall===
====Release.IsInstall====
This is set to true if the current operation is an install.
This is set to true if the current operation is an install.
  &#123;{ .Release.IsInstall }}
  &#123;{ .Release.IsInstall }}
===Release.Service===
====Release.Service====
Exposes the releasing service - always Tiller
Exposes the releasing service - always Tiller
 
===Files===
==Files==
===Capabilities===
==Capabilities==
===Template===
==Template==


=TODO=
=TODO=

Revision as of 03:20, 29 August 2019

External

Internal

Overview

Templates are files living under a chart's templates/ directory. They are written in YAML with Helm templates extensions. Upon processing by Helm, they become Kubernetes manifest files. Helm template extensions are written in the Help template language, which is based on Go templates.

The templates/ Directory

The 'templates' directory contains templates that, after combination with values, will the Kubernetes manifests. When Tiller evaluates a chart, it will send all of the files in the directory through the template rendering engine, then collect the results and send them to to Kubernetes.

Template names do not follow a rigid naming pattern. It is, however, recommended to use the suffix .yaml for YAML files and .tpl for helpers.

It also contains the following files:

Files whose names start with "_" or "." will be ignored. - Really? helm install complained about _pod.yaml.

Template Directives

A template directive is enclosed in {{ and }} blocks, and it is recommended to pad the directive with space at its left and right.

Simple Replacement

The simplest directive is a value, which is a namespaced object, where each dot (.) separates each namespaced element. A leading dot indicates that we start with the top-most namespace for the scope.

kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap

Scopes

Template Objects

Built-in Objects

Built-in Objects

Chart

Exposes all contents of Chart.yaml. An existing field is available as (note leading dot) .Chart.<UpperCasedFirstLetterFieldName>.

Example:

{{ .Chart.Name }}
{{ .Chart.Version }}

Values

Release

Release.Name

Exposes the release name:

{{ .Release.Name }}

Release.Revision

Exposes the release revision:

{{ .Release.Revision }}

Release.Time

Exposes the time of the release:

{{ .Release.Time }}

Release.Namespace

Exposes the namespace to be released info, if the manifest does not override:

{{ .Release.Namespace }}

Release.IsUpgrade

This is set to true if the current operation is an upgrade or rollback.

{{ .Release.IsUpgrade }}

Release.IsInstall

This is set to true if the current operation is an install.

{{ .Release.IsInstall }}

Release.Service

Exposes the releasing service - always Tiller

Files

Capabilities

Template

TODO

Template Comments

# This is a comment
{{- /*
This is another comment
*/ -}}

TODO