concept ConfigMaps in category kubernetes

This is an excerpt from Manning's book Learn Kubernetes in a Month of Lunches.
Kubernetes supports configuration injection with two resource types: ConfigMaps and Secrets. Both types can store data in any reasonable format, and that data lives in the cluster independent of any other resources. Pods can be defined with access to the data in ConfigMaps and Secrets, with different options for how that data gets surfaced. In this chapter you'll learn all the ways to manage configuration in Kubernetes, which are flexible enough to meet the requirements for pretty much any application.
Figure 4.4 Pods can load individual data items from ConfigMaps and rename the key
![]()
Creating ConfigMaps from literal values is fine for individual settings, but it gets cumbersome fast if you have lots of configuration data. As well as specifying literal values on the command line, Kubernetes lets you load ConfigMaps from files.
4.2 Storing and using configuration files in ConfigMaps
Options for creating and using ConfigMaps have evolved over many Kubernetes releases, so they now support practically every configuration variant you can think of. These sleep pod exercises are a good way to show the variations, but they're getting a bit boring so we'll just have one more before we move onto something more interesting. Code listing 4.3 shows an environment file - a text file with key-value pairs which can be loaded to create one ConfigMap with multiple data items.
Code listing 4.3 - ch04.env, a file of environment variables
# environment files use a new line for each variable KIAMOL_CHAPTER=ch04 KIAMOL_SECTION=ch04-4.1 KIAMOL_EXERCISE=try it nowEnvironment files are a useful way to group together multiple settings, and Kubernetes has explicit support for loading them into ConfigMaps, and surfacing all the settings as environment variables in a pod container.

This is an excerpt from Manning's book Kubernetes in Action.