Course contentsShow
← Cloud and Infrastructure
Lesson 1537 of 2,98931. Helm Package ManagerFree lesson

Template Basics and Go Templating

Learn Helm's template syntax using Go templates, including variables, pipes, and basic template structure.

Template Basics and Go Templating

What you'll learn: How Helm uses Go's templating language to dynamically generate Kubernetes manifests from templates.

What Are Helm Templates?

Helm templates are YAML files with embedded Go template expressions that allow you to inject values, apply logic, and reuse configurations. Think of them like a mail merge for Kubernetes manifests—you write one template with placeholders, and Helm fills in the specifics based on your values.

Go Template Syntax Basics

Templates live in the templates/ directory of your chart. Here's the core syntax:

Variables and Values

Access values from your values.yaml using double curly braces:

apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.serviceName }}
spec:
  type: {{ .Values.serviceType }}

The .Values object references your values file. The leading dot (.) represents the current scope.

Pipes

Pipes (|) let you chain functions together, passing output from one to the next:

name: {{ .Values.appName | upper | quote }}

This takes appName, converts it to uppercase, then wraps it in quotes—just like Unix pipes.

Template Structure

Every template starts with the root context (.). Common built-in objects include:

  • .Values - your custom values
  • .Release - release metadata (name, namespace)
  • .Chart - Chart.yaml metadata

Templates generate text output. Helm processes them, then applies the resulting YAML to Kubernetes.

Why This Matters

Templates transform static YAML into reusable, configurable packages. Instead of maintaining separate manifests for dev, staging, and production, you maintain one template with different values files.

Key Takeaway: Helm templates use Go's text/template syntax with variables (.Values), pipes for function chaining, and built-in objects to dynamically generate Kubernetes manifests from reusable patterns.