Kubernetes in Action, Second Edition MEAP V15 cover
welcome to this free extract from
an online version of the Manning book.
to read more
or

9 Configuration via ConfigMaps, Secrets, and the Downward API

 

This chapter covers

  • Setting the command and arguments for the container's main process
  • Setting environment variables
  • Storing configuration in config maps
  • Storing sensitive information in secrets
  • Using the Downward API to expose pod metadata to the application
  • Using configMap, secret, downwardAPI and projected volumes

You’ve now learned how to use Kubernetes to run an application process and attach file volumes to it. In this chapter, you’ll learn how to configure the application - either in the pod manifest itself, or by referencing other API objects within it. You’ll also learn how to inject information about the pod itself into the application running inside it.

Note

9.1 Setting the command, arguments, and environment variables

Like regular applications, containerized applications can be configured using command-line arguments, environment variables, and files.

9.1.1 Setting the command and arguments

9.1.2 Setting environment variables in a container

9.2 Using a config map to decouple configuration from the pod

9.2.1 Introducing ConfigMaps

9.2.2 Creating a ConfigMap object

9.2.3 Injecting config map values into environment variables

9.2.4 Injecting config map entries into containers as files

9.2.5 Updating and deleting config maps

9.2.6 Understanding how configMap volumes work

9.3 Using Secrets to pass sensitive data to containers

9.3.1 Introducing Secrets

9.3.2 Creating a secret

9.3.3 Using secrets in containers

9.4 Passing pod metadata to the application via the Downward API

9.4.1 Introducing the Downward API

9.4.2 Injecting pod metadata into environment variables

9.4.3 Using a downwardAPI volume to expose pod metadata as files

9.5 Using projected volumes to combine volumes into one

sitemap