liveBook · Manning

Base64

As explained in Kubernetes in Action, Second Edition

Base64 encoding represents binary or textual data as printable characters without providing confidentiality.

Base64 encoding represents binary or textual data as printable characters. It is an encoding format, not encryption: anyone who can read a Base64 value can decode the original data. Kubernetes uses it where YAML and JSON cannot directly represent binary values. section 8.3.1 section 8.3.4

In a Kubernetes Secret, values in data must be Base64-encoded. The encoding applies to the manifest representation only. When Kubernetes injects the Secret into a container as an environment variable or file, it decodes the value so the application receives its original form. section 8.3.1

Base64 appears in several closely related Kubernetes fields:

  • Secret data stores key–value pairs as Base64-encoded strings. section 8.3.1
  • Secret stringData accepts plain text when manually encoding would be inconvenient; retrieving the object exposes the value through data as Base64. section 8.3.1
  • ConfigMap binaryData stores binary content as Base64 because YAML and JSON do not inherently support binary data. section 8.3.1 section 8.2.2

A generated ConfigMap manifest

Running kubectl create configmap with a text file and a binary file places the text in data and the binary content in binaryData. The generated binaryData value appears as a Base64 string, while the text remains readable. section 8.2.2

Table 8.3 Differences in the structure of Secrets and ConfigMaps
Secret
ConfigMap
Description
data
binaryData
A map of key–value pairs. The values are Base64-encoded strings.
stringData
data
A map of key–value pairs. The values are plain text strings. The stringData field in Secrets is write-only.
immutable
immutable
A Boolean value indicating whether the data stored in the object can be updated.
type
N/A
A string indicating the type of Secret. It can be any string value, but several built-in types have special requirements.

Compare Secret data and stringData with ConfigMap binaryData and data to see where Base64 is required and where plain text is accepted. section 8.3.1

Base64 does not make sensitive data confidential. Secret access still depends on permissions, storage protection, and handling after injection; exposed encoded values remain easy to read. section 8.3.4

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains manifest encoding, decoding during container injection, and the distinction from encryption without detailing the encoding algorithm.
Examples
Uses Secret data, Secret stringData, ConfigMap binaryData, and kubectl-generated manifests containing binary files.
What it assumes
Assumes familiarity with Kubernetes objects and YAML or JSON manifests while teaching that encoding does not provide encryption.
What you can do after
Apply it via kubectl by recognizing encoded manifest values and distinguishing readable text from binary data.
How it connects
Connects Base64 with Kubernetes Secrets, ConfigMaps, YAML, JSON, container injection, and encryption.

Also explained in

Compare how 7 books explain Base64 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.