0Pricing
Helm Academy · Lesson

Encoding with b64enc, toYaml, and indent

Serializing structures into valid manifests.

Encoding with b64enc, toYaml, and indent is a free Helm Academy lesson on CoddyKit — lesson 4 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.

Serializing Structured Values

Sometimes a value is a whole object, not a string. Helpers like toYaml turn structures into valid manifest fragments.

Rendering Maps with toYaml

The toYaml function converts a map or list from your values into properly formatted YAML text.

{{ toYaml .Values.resources }}

Indentation Is Everything

Raw toYaml output starts at column zero. Dropped into nested YAML, that breaks the document, so you must indent it.

Shifting Blocks with indent

The indent function adds spaces to every line of a block, aligning serialized output under its parent key.

{{ toYaml .Values.resources | indent 4 }}

Newline-Aware nindent

The nindent helper adds a leading newline before indenting, so the block sits cleanly on its own lines after a key.

resources: {{ toYaml .Values.resources | nindent 4 }}

indent vs nindent

Use nindent right after a key on the same line, and indent when the block already begins on a fresh line.

Base64 with b64enc

Kubernetes Secrets store data Base64-encoded. The b64enc helper encodes a plaintext value into that format. 🔐

password: {{ .Values.password | b64enc }}

Decoding with b64dec

The reverse helper, b64dec, decodes Base64 back to plaintext, handy when reading an existing encoded value.

{{ .Values.encoded | b64dec }}

Encoding Is Not Encryption

Remember that b64enc only encodes; it never secures. Anyone can decode it, so it is not a substitute for real secret management.

Quote Then Encode Strings

For Secret values, often quote first so numeric-looking strings survive, then encode the quoted result with b64enc.

token: {{ .Values.token | quote | b64enc }}

Putting It Together

A typical block combines these: serialize with toYaml, then nindent it under the right key for clean, valid output.

nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}

Quick Check

Which helper both adds a leading newline and indents a block?

Recap

You learned toYaml to serialize, indent and nindent to align, and b64enc to encode Secret data. 🎉

Frequently asked questions

Is the “Encoding with b64enc, toYaml, and indent” lesson free?

Yes — the full text of “Encoding with b64enc, toYaml, and indent” 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 “Encoding with b64enc, toYaml, and indent”?

Serializing structures into valid manifests. 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 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Encoding with b64enc, toYaml, and indent” 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. Piping Values Through Functions
  2. default, required, and quote
  3. String Helpers from the Sprig Library
  4. Encoding with b64enc, toYaml, and indent
← Back to Helm Academy