k8s.github.io

Secrets

In this section, we will take a look at secrets in kubernetes

Web-Mysql Application

web

There are 2 steps involved with secrets

There are 2 ways of creating a secret

Encode Secrets

enc

View Secrets

Decode Secrets

Configuring secret with a pod

There are other ways to inject secrets into pods.

Secrets in pods as volume

Additional Notes: A Note on Secrets

Remember that secrets encode data in base64 format. Anyone with the base64 encoded secret can easily decode it. As such the secrets can be considered not very safe.

The concept of safety of the Secrets is a bit confusing in Kubernetes. The kubernetes documentation page and a lot of blogs out there refer to secrets as a “safer option” to store sensitive data. They are safer than storing in plain text as they reduce the risk of accidentally exposing passwords and other sensitive data. In my opinion it’s not the secret itself that is safe, it is the practices around it.

Secrets are not encrypted, so it is not safer in that sense. However, some best practices around using secrets make it safer. As in best practices like:

Also the way kubernetes handles secrets. Such as:

Read about the protections and risks of using secrets here

Having said that, there are other better ways of handling sensitive data like passwords in Kubernetes, such as using tools like Helm Secrets, HashiCorp Vault. I hope to make a lecture on these in the future.

K8s Reference Docs