0Pricing
Helm Academy · Lesson

Defining a Partial with define

Declaring a reusable named template block.

Defining a Partial with define is a free Helm Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Repeat Yourself?

The same labels and names get copied into every manifest in a chart. A named template lets you write that block once and reuse it everywhere.

Meet the define Action

You declare a reusable block with the define action. It names a chunk of template text but does not render anything on its own.

{{- define "mychart.labels" -}}
app: my-app
{{- end -}}

Anatomy of a define Block

Every define opens with a name string and closes with end. Whatever sits between the two is the body that callers will pull in.

{{- define "NAME" -}}
  ...body...
{{- end -}}

Naming Conventions Matter

Names are global across the whole chart, so prefix them with the chart name to avoid clashes. The dot-style chart.purpose form is the convention.

{{- define "mychart.selectorLabels" -}}
app.kubernetes.io/name: mychart
{{- end -}}

Where Partials Live

By convention all your define blocks go in templates/_helpers.tpl. The leading underscore tells Helm this file emits no manifest of its own.

Underscore Files Are Special

Files in templates that start with an underscore are never rendered into Kubernetes objects. They only hold partials and helpers for others to use.

Define Produces No Output

Defining a partial just registers it by name. Nothing appears in the rendered YAML until another template actually calls that partial.

A Partial Can Use the Dot

Inside a partial you can read context like .Release.Name, but only if the caller passes that scope in. We will cover passing scope soon.

{{- define "mychart.name" -}}
{{ .Release.Name }}
{{- end -}}

Many Partials, One File

You can stack as many define blocks as you like in _helpers.tpl. Group related helpers together to keep the file easy to scan.

{{- define "mychart.name" -}}
my-app
{{- end -}}
{{- define "mychart.fullname" -}}
my-app-prod
{{- end -}}

Partials Build Bigger Charts

As a chart grows, partials keep duplicated labels and names in sync. Change the helper once and every manifest that uses it updates together.

Defining Is Only Half the Job

A define on its own is inert. The next step is inserting it into real manifests with include or template, which the next lesson covers.

Quick Check

You added a define block but the rendered output is empty. Why?

Recap: Defining Partials

You learned to declare reusable blocks with define, name them chart.purpose, and store them in _helpers.tpl. Next you will call them. 🧩

Frequently asked questions

Is the “Defining a Partial with define” lesson free?

Yes — the full text of “Defining a Partial with define” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.

What will I learn in “Defining a Partial with define”?

Declaring a reusable named template block. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Helm Academy?

No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Defining a Partial with define” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Helm Academy lesson?

Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Defining a Partial with define
  2. Inserting Partials with template and include
  3. The Standard Fullname and Labels Helpers
  4. Passing Scope into a Named Template
← Back to Helm Academy