Create Secret

A Secret is an object that contains a small amount of sensitive data

To use a secret, a pod needs to reference the secret. A secret can be used with a pod in two ways: as files in a volume mounted on one or more of its containers, or used by kubelet when pulling images for the pod

Secrets will be stored as base64 encoded values and it will be used mostly during creation of an object

Creating Secrets

From variables
$ kubectl create secret generic my-secret --from-literal=password=mypassword --dry-run -o yaml
From files
$ kubectl create secret generic my-secret --from-file=user=user.txt --from-file=password.txt --dry-run -o yaml
$ echo root >user.txt
$ echo password >password.txt
$ kubectl create secret generic my-secret --from-file=user=user.txt --from-file=password=password.txt --dry-run -o yaml