What Is a Secret?
A ConfigMap provides a way to decouple application configuration data from the application itself. However, the problem with a ConfigMap is that it stores the data in plain text as a Kubernetes object. What if we want to store some sensitive data such as a database password? Kubernetes Secret provides a way to store sensitive data that can then be made available to the applications that require it.
Secret versus ConfigMap
You can think of a Secret as the same as a ConfigMap with the following differences:
- Unlike a ConfigMap, a Secret is intended to store a small amount (1 MB for a Secret) of sensitive data. A Secret is base64-encoded, so we cannot treat it as secure. It can also store binary data such as a public or private key.
- Kubernetes ensures that Secrets are passed only to the nodes that are running the Pods that need the respective Secrets.
Note
Another way to store sensitive data is a vault solution, such as HashiCorp Vault. We have left such...