liveBook · Manning

Kubectl create secret

As explained in Kubernetes in Action, Second Edition

kubectl create secret is a kubectl command for creating Kubernetes Secret resources from command-line inputs or files.

kubectl create secret creates Kubernetes Secret resources from command-line values or files. Use Secrets instead of ConfigMaps for sensitive application data, and specify the Secret type immediately after the command. section 8.3.2

Create credentials and generate a manifest

kubectl create secret generic my-credentials --from-literal user=my-username --from-literal pass=my-password --dry-run=client -o yaml produces a Secret manifest. For plain-text input in a manifest, use stringData instead of data; stringData is write-only and only sets values. section 8.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains literal, file, manifest, stringData, TLS, and registry creation, but does not detail Secret consumption or lifecycle behavior.
Examples
Demonstrates status messages, user credentials, TLS certificates, registry credentials, Docker configuration files, and private-image Pods.
What it assumes
Assumes familiarity with ConfigMaps and Kubernetes resources while contrasting Secret-specific types and sensitive-data handling.
What you can do after
Apply it via kubectl to create generic, TLS, or registry Secrets and generate reusable YAML manifests.
How it connects
Connects Secrets with ConfigMaps, YAML manifests, Kubernetes API objects, Pods, private images, and imagePullSecrets.

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.