- [Instructor] Just like configuration data,
applications might also require other data
that is more sensitive in nature.
For example, like in this scenario,
database passwords or api tokens.
Passing these straight and yml for deployment or pod
would make them visible to everyone.
In cases like these, we'd want to use
something called a secret, let's see what that is.
In order to create a secret,
we can do a kubectl create secret,
we want to create a generic secret,
and let's call it an apikey.
We're going to pass this from literal
and we'll call it api_key equals something like that.
In this scenario we've created the secret,
so let's take a look at our secrets api.
We see a secret of name api key,
type opaque, some data in it.
If you want to take a look at the actual secret,
you can do a kubectl get secret
and we called this api_key.
If we try and do an o yml,
we'll notice that the data portion has the api key,
but we have a different value from what we initially typed.
That is because this value is encoded in the base 64 format.
Now how do you actually use
these secrets with an application?
We have an example application in
our exercise files called secret reader.
Looking at that, this is very similar
to using a config map, but instead of configmapref,
we use secretref, we called our secret apikey,
so we pass that as the name
and the actual key in that was called api_key.
So let's deploy this guy.
Ctl create, the deployment for
the secret reader has been created.
Let's see if our pods are running.
The pod is running.
I'm going to copy this and look inside the pod.
The pod in this instance is just printing out the value
passed to it via an environment variable,
but the value is hidden behind the secret
and is protected from the casual observer.