Secrets

Learn how to put the latest open source technology into practice with hands-on training, delivered by industry experts, aligned to your desired business outcomes

Secrets hold sensitive information, such as passwords, OAuth tokens, and SSH keys. Putting this information in a secret is safer and more flexible than putting it verbatim in a pod definition or a Docker image!

There are three types of secrets, explained by the --help flag:

$ kubectl create secret --help

Create a secret using specified subcommand.
Available Commands:
  docker-registry Create a secret for use with a Docker registry
  generic     	Create a secret from a local file, directory or literal value
  tls         	Create a TLS secret

Example of creating a secret imperatively:

$ kubectl create secret generic my-secret --from-literal=username=ckad-user --from-literal=password="Char1!3-K!10-Alpha-D31ta" -o yaml

apiVersion: v1
data:
  password: Q2hhcjFLd2hpbGUgdHJ1ZSA7IGRvIHdoaWNoIHZpbSA7QWxwaGEtRDMxdGE=
  username: Y2thZC11c2Vy
kind: Secret
metadata:
  name: my-secret
  namespace: default
type: Opaque

$

Learn more about secrets.