liveBook · Manning

Opaque secret

As explained in Kubernetes in Action, Second Edition

An opaque Secret is a generic Kubernetes Secret whose data has no specialized built-in interpretation.

An opaque Secret is a generic Kubernetes Secret for sensitive values that have no specialized built-in interpretation. It is useful for application settings such as status messages or user credentials that should not reside in a ConfigMap. section 8.3.2

Create an opaque Secret

Create a generic Secret directly with kubectl: kubectl create secret generic kiada-secret-config --from-literal status-message="This status message is set in the kiada-secret-config Secret". Generic Secrets are limited to approximately 1 MB. section 8.3.2

$ kubectl create secret generic my-credentials \     #1
   --from-literal user=my-username \                #2
   --from-literal pass=my-password \                #2
   --dry-run=client -o yaml        #3
apiVersion: v1
data:
  pass: bXktcGFzc3dvcmQ=           #4
  user: bXktdXNlcm5hbWU=           #4
kind: Secret
metadata:
  creationTimestamp: null
  name: my-credentials

Generate a YAML manifest for credentials with kubectl without manually entering Base64-encoded values. section 8.3.2

You can also define an opaque Secret as a YAML API object. Use stringData for plain-text values such as user and pass; this field is write-only and sets Secret entries. section 8.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains creation with kubectl and YAML, including stringData and generated Base64 values, but not deeper Secret internals.
Examples
Uses a status message, username and password, and generated credential manifests as concrete examples.
What it assumes
Assumes familiarity with ConfigMaps and Kubernetes YAML, while introducing generic Secret creation and stringData from practical examples.
What you can do after
Apply opaque Secrets with kubectl commands or generated YAML manifests, using literals or stringData values.
How it connects
Connects opaque Secrets with ConfigMaps, kubectl, YAML manifests, and the stringData field.

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.