Built-in Objects

Objects are passed into a template from the template engine. And your code canpass objects around (we’ll see examples when we look at the with and rangestatements). There are even a few ways to create new objects within yourtemplates, like with the tuple function we’ll see later.

Objects can be simple, and have just one value. Or they can contain otherobjects or functions. For example. the Release object contains several objects(like Release.Name) and the Files object has a few functions.

In the previous section, we use {{ .Release.Name }} to insert the name of arelease into a template. Release is one of the top-level objects that you canaccess in your templates.

  • Release: This object describes the release itself. It has several objectsinside of it:
    • Release.Name: The release name
    • Release.Namespace: The namespace to be released into (if the manifestdoesn’t override)
    • Release.IsUpgrade: This is set to true if the current operation is anupgrade or rollback.
    • Release.IsInstall: This is set to true if the current operation is aninstall.
    • Release.Revision: The revision number for this release. On install, this is1, and it is incremented with each upgrade and rollback.
    • Release.Service: The service that is rendering the present template. OnHelm, this is always Helm.
  • Values: Values passed into the template from the values.yaml file and fromuser-supplied files. By default, Values is empty.
  • Chart: The contents of the Chart.yaml file. Any data in Chart.yaml willbe accessible here. For example {{ .Chart.Name }}-{{ .Chart.Version }} willprint out the mychart-0.1.0.
  • Files: This provides access to all non-special files in a chart. While youcannot use it to access templates, you can use it to access other files in thechart. See the section Accessing Files for more.
    • Files.Get is a function for getting a file by name (.Files.Getconfig.ini)
    • Files.GetBytes is a function for getting the contents of a file as anarray of bytes instead of as a string. This is useful for things likeimages.
    • Files.Glob is a function that returns a list of files whose names matchthe given shell glob pattern.
    • Files.Lines is a function that reads a file line-by-line. This is usefulfor iterating over each line in a file.
    • Files.AsSecrets is a function that returns the file bodies as Base 64 encodedstrings.
    • Files.AsConfig is a function that returns file bodies as a YAML map.
  • Capabilities: This provides information about what capabilities theKubernetes cluster supports.
    • Capabilities.APIVersions is a set of versions.
    • Capabilities.APIVersions.Has $version indicates whether a version (e.g.,batch/v1) or resource (e.g., apps/v1/Deployment) is available on thecluster.
    • Capabilities.Kube.Version is the Kubernetes version.
    • Capabilities.Kube is a short form for Kubernetes version.
    • Capabilities.Kube.Major is the Kubernetes major version.
    • Capabilities.Kube.Minor is the Kubernetes minor version.
  • Template: Contains information about the current template that is beingexecuted
    • Name: A namespaced file path to the current template (e.g.mychart/templates/mytemplate.yaml)
    • BasePath: The namespaced path to the templates directory of the currentchart (e.g. mychart/templates).The built-in values always begin with a capital letter. This is in keeping withGo’s naming convention. When you create your own names, you are free to use aconvention that suits your team. Some teams, like the KubernetesCharts team, choose to use only initial lowercase letters in order to distinguish local names from those built-in. In thisguide, we follow that convention.