liveBook · Manning

Secret data field

As explained in Kubernetes in Action, Second Edition

The stringData field is a Secret field that accepts plain-text key-value data and is converted into the data field when stored.

The stringData field lets a Kubernetes Secret accept plain-text key-value pairs. Kubernetes converts those entries into the Secret's data field as Base64-encoded values when storing the object. section 8.3.1

Define credentials without manual encoding

apiVersion: v1 kind: Secret stringData: user: my-username pass: my-password After applying this manifest, retrieving the Secret with kubectl get -o yaml no longer shows stringData. The entries appear under data as Base64-encoded strings. The field is therefore write-only: use it to set values, not to read them back. section 8.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains declaration, storage conversion, and read-back behavior, but does not detail API-server implementation.
Examples
Uses user and password entries in a Secret manifest, then contrasts stringData with encoded data on retrieval.
What it assumes
Assumes familiarity with YAML and Secret objects while teaching the plain-text-versus-Base64 distinction.
What you can do after
Builds a Secret manifest with readable values and recognizes why retrieved values appear under data instead.
How it connects
Relates Secrets to ConfigMaps, Base64 encoding, YAML manifests, and kubectl.

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.