Kubernetes YAML Config and Secrets/Opaque Secret with stringData

Author readable Secret YAML without manual base64.

Section: Secrets

Opaque Secret with stringData

yaml
yaml
apiVersion: v1
kind: Secret
metadata:
  name: app-secrets
type: Opaque
stringData:
  DATABASE_URL: postgres://app:secret@postgres:5432/app
  API_KEY: replace-me
Explanation

Use `stringData` in YAML authoring; the API server handles encoding into Secret data fields.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Secrets
Read specific secret keys into env vars
Map one Secret key to one variable.
OpenIn sheetyamlsame section
Mount Secret as files
Expose certificate or key material through a volume.
OpenIn sheetyamlsame section
Create Secret from literals
Generate a Secret without hand-editing YAML.
OpenIn sheetbashsame section
Combine Secret and ConfigMap into one volume
Project multiple sources into a single directory.
OpenIn sheetyaml1 tag match
Basic ConfigMap YAML
Key-value application config in YAML.
ConfigMap with file-like content
Mount application config files from YAML.