Kubernetes 101 : Environment variables

The environment variables are used to make parameters available to different kubernetes objects.

We could use environment variables in a YAML file for example as below:

We set the environment variables at the container level.
We could use them for example in the YAML file, on a command in the container:

We could also pass them through the deployment on the command line using the below commands.
We first, create our deployment:

Then we set our environment variables:


Using configMaps to store environment variables for example, gives us more flexibility than hard-coding them inside the containers
We don't have to create different versions of the same pod, we just create different configMaps and attach them to our copies of the pod


Leave as a comment: