Beginners guide to Secrets and ConfigMaps

Saiyam Pathak avatar
By Saiyam Pathak
Director of Technical Evangelism

Description

How are Secrets and ConfigMaps mounted inside a container and then used within cluster administration.


Transcription

What are Kubernetes secrets?

In this video, we'll be going through another set of ephemeral volumes: secrets and ConfigMaps. A secret in Kubernetes is used to store secret data and ConfigMap for a set of configurations. These can be mounted as a volume inside a container.

You can see a simple example of a secret where you have created a username and password in base64 encoded. This is a pod with a secret pod volume name and a simple Nginx image. Now we have used a volume, which is of type secret. The volume plug-in over here is secret, and we define a secret name, so the secret name will be the same as the secret created. And then, inside the container and volumeMount section, we provide the volume's name.

What is a ConfigMap in Kubernetes?

Similarly, for ConfigMap, we create a ConfigMap, create a name and namespace, and then give the data. First, specify what data we want to store inside the ConfigMap. Then inside the pod, we'll go to the pod spec section.

In the volume section, we have used ConfigMap as a volume plug-in. And the name we have given is ConfigMap for volume, which is the same as the ConfigMap we just created. Inside the container, we have a volumeMount corresponding to the same volume.

That's how secrets and ConfigMaps can be mounted inside a container using volumes. That's it for this lecture. Thanks for watching. See you in the next one.

Don't stop now, check out your next lesson