But our password secret is also there. Great success!
How can we see it.
Lets describe said resource
The kubectl command helpfully hide
But this is not secure at all. We can just see it by looking at the yaml representation of the secret.
This prints
We can just copy that string and decode that and get the password in text.
Or we can do that with a little bit of linux magic
Using jsonpath we are extracting the password from the json output that piping that to base64 decode.
And with that we get our super-secret-password back. Not so secure.
Using Kubectl
We can also create secret directly using kubectl
Run
Different method same out come.
Consuming Secret
Creating a secret means nothing if we can't use it.
There are basically two ways you can consume secret in a kubernetes environment.
Passed as an environmental variable
Mounted a volume and consumed as a file
Environmental Variable
The issue with this approach is that kubernetes does not do any kind of differentiation between a password env variable and a regular environmental variable. So if your application does log out things anywhere it often writes the env variable in case of a crash. So you will leak your own secrets.
Volume Mount
This is a bit more secure than env vars. But if someone gets access to the running pod, they can literally read the file. We need to make our images more secure, but thats a separate workshop on its own.
What do we do?
So the secrets on kubernetes is bad, I hope we all see that.
Then what do we do?
We could encrypt our own secrets, use encrypted inter cluster communication for the time we are passing secrets. We can encrypt our etcd cluster which is the underlying storage for kubernetes.
The major cloud providers have key management systems that can be used in this way. Other third-party solutions include HashiCorp Vault and CyberArk Conjur.